Meteor-Community-Packages / ground-db

GroundDB is a thin layer providing Meteor offline database and methods
https://atmospherejs.com/ground/db
MIT License
572 stars 77 forks source link

Auto cleanup as data grows #192

Open ramezrafla opened 7 years ago

ramezrafla commented 7 years ago

Is there an easy way to clean up docs in a groundDB to prevent it from growing? Should we simply listen to isDone event and call keep when it goes over a number of docs?

raix commented 7 years ago

you could in theory add some offline metrics like size/usage/age of documents, then have a sort function using weights to figure out the most important documents. I've done this in the past and wanted this in gdb at some point. It's something to think about.

ramezrafla commented 7 years ago

Thanks @raix

I had an idea to make sure we keep data well sync-ed with server. The problem is with all the subscriptions, it's tricky running a keep as you may lose data that is still on server but not subscribed to yet.

We could have a server method to which we send all the ids currently in gdb and it returns the ones that are valid, and we would run on the client a keepIds (a clone of keep but that depends on id's).

Thoughts? If you are willing to accept a PR, I could work on it. It could be a simple client method called sync() that would take care of everything.