-->

Parse. Keep LocalDataStore data sync

2019-02-07 15:12发布

问题:

I'm query the data online first(without "[query fromLocalDatastore];"). And "pin' it for local usage. To save bandwidth, i'm using "UpdatedAt" to get only the new stuff.

After, I query using "[query fromLocalDatastore];

it work great to get datas. :)

But the question was: How to sync my local datas with data that are deleted from the Parse dashboard?

Exemple: Getting new stuff can return zero element, But, maybe they are 10 element deleted online.

Edit: The final goal was to have 10000 rows In parse dashboard. And grab only updated or deleted(instead of all stuff)

回答1:

In this case, I would suggest to not use a physical delete but a logical delete. Add a new Boolean column called "deleted", when you query from the device you'll get all the data and if something has been deleted, you'll know it.

You should also use a second column called "sync" to indicate that the deleted row has been updated locally and then use a background job (periodicity depends on your needs) to physically delete those rows. I think this action is important in order to safely clean your database. If you leave all your deleted rows in your database, at some point your queries might get affected in terms of speed.

I hope it helps.

Javier.



回答2:

Please refer these links, These links bind parse.com webservices (bind parse classes) with local data(core data) and you can update local data with insertion and deletion of parse.com database classes records.

http://www.raywenderlich.com/15916/how-to-synchronize-core-data-with-a-web-service-part-1

http://www.raywenderlich.com/17927/how-to-synchronize-core-data-with-a-web-service-part-2

Hopefully, this will help you. :)