I have a collection in which documents are written online when from our nodeJS backend using mongoose. In order to support offline mode, I am using realm to create documents locally in the react native app and store in realm which in turn syncs it with the Atlas database. But, now I want to remove created document from the local realm database as it is no longer of use. Also, I want to restrict the documents created from the backend to be written to the sync as it will unnecessarily increase my storage consumption.
I have two solutions for the above:
- Use a boolean in the collection which is changed in a trigger when the documents syncs with the Atlas database. I use this as a filter in the local realm query to remove it from the local database. However, this still leads to the unnecessary write of documents created from backend to sync database.
- Use asymmetric sync to only write the documents from client to Atlas. I am unable to find a way to delete it from the local database in this case after it is written to atlas database.