ground-db icon indicating copy to clipboard operation
ground-db copied to clipboard

Better understanding cleanupLocalData: false

Open isAlmogK opened this issue 10 years ago • 13 comments

I'm trying to better understand cleanupLocalData: false @raix maybe you can help explains this a bit. If cleanupLocalData is set to false my understanding that the local saved data is never cleaned up IE deleted and this is per browser / device. Is that correct?

If this is set to true or not set at all how is the local data removed / deleted and when? What triggers it? Also if your using iron-router and waitOn how is it deleted in that context?

Thanks, Almog

isAlmogK avatar Jun 05 '15 19:06 isAlmogK

As far as I can see in the source, it always keeps the data in the browser. If a subscription gets [A, B, C] and then C is removed, you still have [A, B, C], but the Ground.Collection only shows you [A, B], since that's how it's supposed to work. If you, later on, get C from the subscription, it should be faster than re-downloading the data, since you already have it grounded.

If this is set to true or not set at all how is the local data removed / deleted and when? What triggers it? Also if your using iron-router and waitOn how is it deleted in that context?

If it is set to true, it is never deleted. If it is not set or set to false, GroundDB checks for changes in the pub/sub and deletes the data if it's not needed anymore.

Please note: I didn't test anything. I just did a quick lookup at the code.

fermuch avatar Jun 14 '15 14:06 fermuch

normally grounddb will clear all localOnly documents on subscription ready - but this can be done manually also: https://github.com/GroundMeteor/db#additional-api

raix avatar Jun 15 '15 08:06 raix

When we tested it out I ran into the following issue I have A, B, C data which syncs with the tablet, the tablet goes offline and later on a different user deletes C online. Again a day later the tablet that was offline goes online and resyncs now C which was deleted is back.

Should I set local data to false? Is this supposed to happen?

isAlmogK avatar Jun 18 '15 07:06 isAlmogK

@almogdesign sounds like we might need to implement conflict resolution

raix avatar Jun 18 '15 09:06 raix

Yes, I would keep it simple the database should always be right and they when making changes like edit or delete this should only be done in online mode and should be the developers responsibility , we're implemented that in our app.

@raix do you think you can do this in a quick update?

isAlmogK avatar Jun 18 '15 09:06 isAlmogK

@almogdesign by turning of update/remove? - I've been thinking about having an option:

resume: {
  insert: true,
  update: false,
  remove: false
}

Where pr. default all method resumes would be turned off - making grounddb a cache only layer pr. default.

raix avatar Jun 18 '15 12:06 raix

gosh - I already implemented a resume = false option.

so if you only want inserts to resume you could:

    Ground.methodResume([
      '/' +collectionName + '/insert'
   ]);

raix avatar Jun 18 '15 12:06 raix

Great so add the ground method resume

it will solve the issue of C being reinserted into the database.

How does it now it was deleted?

isAlmogK avatar Jun 18 '15 13:06 isAlmogK

@raix is that correct?

isAlmogK avatar Jun 19 '15 13:06 isAlmogK

via the subscription and the cleanupLocalData

raix avatar Jun 19 '15 14:06 raix

Is there an example of this somewhere I want to make sure I get it right

isAlmogK avatar Jun 19 '15 14:06 isAlmogK

What exactly is local only data?

malhal avatar Aug 04 '15 12:08 malhal

data created on the client only or data removed on the server

raix avatar Aug 04 '15 15:08 raix