I'm looking for a way to replicate an rxdb instance locally, in the browser (local storage to local storage). I read somewhere that this is the only way to purge deleted items (can't find the link now). Actually, what I would like to do is:
- purge deleted items (deleted flag set)
- purge old revisions (older than a certain timestamp) However I can't find an example of how to do this. I need to purge often because my data changes very often and I would quickly outrun browser storage (as well as rows in my remote database that I'm syncing to).
This is my rough idea based on rxdb docs:
// transfer data
const jsonResult = await myCurrentDb.things.dump()
const filteredJsonResult = jsonResult.filter(_ => !(_.deleted) && <latestRevision>)
// wipe current collection
await myCurrentDb.things.remove()
await myCurrentDB.collection({name: 'things', ... }) // recreate
// re-import
myCurrentDb.things.importDump(filteredJsonResult)
Questions:
- I am thinking of running this clientside, intermittently (maybe once every 30 minutes?) Would this approach be OK? Am I missing something or is dump/importDump not the way to go?
- I need help figuring out the logic for the "latestRevision" condition in the filter? How do I figure that out?