One way syncing

I’m new to MongoDB and Realm sync. I currently working on a React Native project and I want to be able to store app data to cloud , but if the data is deleted in the app, the cloud data remains untouched. It appears that in order to allow writing to Realm Sync, you must also enable reading…in other words no write-only. Is there another way I’m missing?

Thanks,
Les

Hey, sorry I am a little bit confused about what you are trying to do. Are you trying to have an insert/update only mode where deletes are not synced? Or are you trying to have only writing enabled and no reading (it seems like your conclusion is this but im not following your example). Do you mind elaborating a bit more on what you are trying to do?

Thanks,for replying. If I write data to client Realm, it syncs to Atlas. If I delete that data on the client, then Atlas data is deleted, as you would expect. But I want the Atlas data to be persistent…immutable in fact.

Thanks,for replying. If I write data to client Realm, it syncs to Atlas. If I delete that data on the client, then Atlas data is deleted, as you would expect. But I want the Atlas data to be persistent…immutable in fact.

Got it. Technically what you are talking about doing is opting in and out of synchronization which breaks a few of the underlying assumptions of sync.

We have heard this as a point of feedback though, especially in terms of having an insert-only collection where changes sync to atlas and then no changes to that object will ever be synced down. We are planning a project in the coming months to add this “async-insert” functionality, so let me know if that sounds like it fits your needs.

1 Like

Tyler, simply, I want to delete a document in the local realm, and not have that document deleted in the Atlas.
Thanks,
Les

Hi, currently there is no official way to do this because sync ensures that all of the data matching your query is syncing to the device. As a workaround, I would recomend using flexible sync and having a field in your document called “evicted”. Then you can sync down your query (for example "status==‘urgent’ && priority > 10 && evicted==false). Then, when you want to remove the object from the device, you can just set evicted to true and it will be removed.

We may in the future look into having this as an officially supported feature, but doing so could cause major scalability concerns as it would likely involve a lot of book keeping to be done by the server for every object being synced to every connected client. So, currently the workaround would be to just tighten your subscription to remove documents you no longer care about.

Let me know if that works,
Tyler

1 Like

Thank you, that was very helpful.
Les

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