rxdb: RxDB does not respond to collection.remove() changes.
Version: 13 - 15 environment:: chrome
Issue:
When attempting to remove all data from a collection using collection.remove(), the data remains in other tabs until they are reloaded. I suspect this issue might also be related to the fact that we cannot listen to the collection.remove(), operations.
Expected Outcome:
The collection.remove() method should be listened to in other tabs as well as through hooks similar to all other operations - bulkRemove, update, create operations.
Step to reproduce: 1)Open the application in 2 tabs. 2)Clear the collection using the remove() method. 3)Verify that there is no data left in the collection on the current page (specifically not in the indexedDB storage but in the RxDB instance itself). 4)Open another tab and ensure that the data is still available (possibly because RxDB does not react to collection remove operations unlike other operations).
What do I mean when comparing with other operations? We have a set of hooks that allow us to listen to various database operations:
preInsert
postInsert
preSave
postSave
preRemove
postRemove
postCreate
So, the operation collection.remove() cannot be listened to in this way. Although it may have nothing to do with the described problem.
About this issue
- Original URL
- State: open
- Created 4 months ago
- Reactions: 5
- Comments: 18 (8 by maintainers)
@pubkey Instead of implementing this on our own, would it be an option to fund this feature?
Our goal is to have a bulletproof logout, which cleans all data in the browser (when using persistent storages like indexeddb). We encountered different problems on this matter:
We are experimenting with cleaning up the data with bulkRemove/cleanup, so the events are send to all tabs and data is purged. For the interrupted logout we are setting a flag, which indicates, that the logout/cleanup was not finished and will be resumed on next load, but we think, that it is more working around the problem and probably leading to other problems in the future.
So the requirement would be to have a bulletproof way to reset the data to an empty state as fast as possible, informing all open tabs and considering conditions like reloads. Are you open to discuss a funded solution?
Thanks for the input. @AleksandrMatuka let’s discuss this.
No,
postRemoveRxCollectionis what I found in the code base, and it looks like it’s in the right spot, but I haven’t tried it myself.There is also the
postRemoveRxCollectionhook that might help? By the way, there already is anRxCollection.remove$observable, but it only gets triggered on single document deletion.