From 310e3d7a039338c2ecea7473784683ac4013bf88 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 8 Oct 2015 15:31:29 -0700 Subject: [PATCH] Don't store transient arrays returned by RPC --- lib/results.js | 2 +- src/RealmRPC.mm | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/results.js b/lib/results.js index c5f3f7e4..4f682bb7 100644 --- a/lib/results.js +++ b/lib/results.js @@ -14,7 +14,7 @@ function create(realmId, info) { let size = info.size; results[realmKey] = realmId; - results[idKey] = info.resultsId; + results[idKey] = info.id; results[resizeListKey](size); diff --git a/src/RealmRPC.mm b/src/RealmRPC.mm index d50d7e9a..d38d664e 100644 --- a/src/RealmRPC.mm +++ b/src/RealmRPC.mm @@ -239,10 +239,10 @@ using RPCRequest = std::function; } JSObjectRef jsObject = JSValueToObject(_context, value, NULL); - RPCObjectID oid = [self storeObject:jsObject]; if (JSValueIsObjectOfClass(_context, value, RJSObjectClass())) { realm::Object *object = RJSGetInternal(jsObject); + RPCObjectID oid = [self storeObject:jsObject]; return @{ @"type": @(RJSTypeGet(realm::PropertyTypeObject).c_str()), @"id": @(oid), @@ -251,6 +251,7 @@ using RPCRequest = std::function; } else if (JSValueIsObjectOfClass(_context, value, RJSArrayClass())) { realm::ObjectArray *array = RJSGetInternal(jsObject); + RPCObjectID oid = [self storeObject:jsObject]; return @{ @"type": @(RJSTypeGet(realm::PropertyTypeArray).c_str()), @"id": @(oid), @@ -260,9 +261,10 @@ using RPCRequest = std::function; } else if (JSValueIsObjectOfClass(_context, value, RJSResultsClass())) { realm::Results *results = RJSGetInternal(jsObject); + RPCObjectID oid = [self storeObject:jsObject]; return @{ @"type": @"ObjectTypesRESULTS", - @"resultsId": @(oid), + @"id": @(oid), @"size": @(results->size()), @"schema": [self objectSchemaToJSONObject:results->object_schema] };