MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

Limit Sync to database instead of cluster

When enabling Sync (which is still in beta), you have to select a cluster, in which all databases and collections will be synced automatically. I would like to have collections that are external to the sync process — like a “users” collection for instance, I don’t want all clients to store all users on their device.

If you don’t specify a schema for a collection, it will be omitted from Sync, however this yields red errors in the Sync UI, and I can’t seem to set permission rules for this collection, since the message Sync is in Beta: Permissions for this synced collection are set on the synced cluster. Visit the Sync page is displayed.

You could create another cluster dedicated to collections that are not synced, but this is inconvenient for the following reasons:

  1. You can have only one free cluster (useful while in development).
  2. From what I understand, you’d still need the users connected to the two clusters, so you can quickly reach the limitation of “max connections” (1500 for M10 for instance, which is not that much), therefore you can’t use a small cluster for this, you’d have to pay a second cluster of about the same level as your first one.

Therefore, is it possible to limit the Sync to the database-level, since you can have multiple databases running on the same cluster? If it’s not possible, that would be a great feature to add.

Hey Realm devs, is this something you might add in the future or is there a specific reason not to?

Still haven’t found a solution to this. It seems that with Sync enabled, permissions set in the Rules>Permissions tab are overridden. I have a user collection that I don’t know how to handle.

How to have collections that are external to the sync process, with custom permissions?

@Jean-Baptiste_Beau Your understanding is correct. When enabling sync - sync permissions take precedence. If you don’t want to a collection to sync - you simply do not give it a partitionKey value/field and it will not be syncable down to the client.

If you are trying to use rules on a separate collection that is not part of sync what you can do is create a separate sever-side Realm App which is just for your web or other API traffic but connect it to the the same MongoDB Atlas cluster as the Realm Sync app. You will be apply your rules there. You can see an example of this here -

We realize this is a workaround and are looking to unify the permissions system in the near future.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.