Sync partial synced realm data at start


#1

Hi, I’ve finished an APP for a client but I would like to understand if there is a better practice to load data on realm connection. Now I’m doing like this:

    const config = user.createConfiguration({
      schema: [Collection1, Collection2, ...],
      schemaVersion: 1
    });
    // Open the Realm

    const realm = new Realm(config);

    

    realm.objects('Collection1').subscribe()
    realm.objects('Collection2').subscribe()
    ...

Is there a better way to subscribe to all available data? I’m using a partial synced Realm (reference in Realm Studio)

Thanks in advice.


#2

@au.petrone If you want to sync all data in a realm why not just use a full-sync API - https://docs.realm.io/sync/using-synced-realms/syncing-data#full-synchronization


#3

Will the fine-grained permission system work with that?


#4

@au.petrone No unfortunately not - the permissions systems are for separate sync systems. So you will have to cycle through each object and create a subscription for all objects in that class. Please note that you only have to do this for parent objects since all child objects are pulled in implicitly.


#5

When you say 'cycle through each object and create a subscription for all objects in that class.’ you mean that I can only query for all objects in that class and subscribe to them as i’ve done in my example, right?

Thank you for helping!