Replace collection with new set of documents as an atomic operation
Many time, we have a collection that is created using data received from an API call and the collection needs to be reset to the new data received in the next API call. For e.g., I have a collaborative app. Each user can see who else in their address-book using the app, such that they can collaborate with them. I send the phone contacts to the backend and we check which contacts and using the app and initialize the contacts collection. The phone contacts are synched every day. The next day, when we get the phone contacts, I want simply find out who is using the app and replace the contacts collection with that data without finding out who was already present in the contacts collection, which contact data has changed and which contacts is no longer there. Currently, if I delete the collection and then recreate with new set of documents, the realtime update listener is triggered with empty collection causing unwanted behavior in the app.