Query-based Sync not retaining data locally


(Arman Sharafshahi) #1

I have implemented a query-based sync (reference) realm in the cloud ROS and loaded it with several hundred thousand objects via a Nodejs app.

Next, I have a React Native app which opens the Realm using the synchronous method:

const realm = new Realm(config)

I understand that this means the first time the app opens I will have nothing in my local app instance. Therefore, I immediately access a subsegment of the records for the user and subscribe to them:

const results = realm.objects('Property').filtered('zip = "75074"');
const subscription = results.subscribe();

I also add listeners to the results and the subscription objects to get status updates and a listener to realm.syncSession.addProgressNotification(…) to get download stats.

Things seem to work in a reasonable way when I first open the app, it appears to begin downloading the (~30mb) of data from cloud ROS and I can then query against this data on the app.

Now, my expectation is that I should be able to close (swipe up on iOS) the app on my device and re-open it and as long as I am subscribing to the same data, it should already be cached on my local device. However, what I do observe is that every restart of the app looks exactly the same and I have to wait for the entire dataset to get downloaded.

Am I not understanding the architecture correctly?

(Kenneth Geisshirt) #2

The data will be removed if the user logs out.

(Arman Sharafshahi) #3

So if my product requires keeping a local version of the database on the device in case the user loses connection and restarts the app, then I cannot use a query-based sync realm? I need them to be able to reboot their iPad and start up with no network connection and be able to see the data that was previously sync’d. This is only possible with full sync?

(Kenneth Geisshirt) #4

You will always have your data locally when you loose connection (both full sync and query-based sync).