Parse. Keep LocalDataStore data sync

2019-02-07 15:02发布

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)

2条回答
爷的心禁止访问
2楼-- · 2019-02-07 15:31

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. :)

查看更多
Fickle 薄情
3楼-- · 2019-02-07 15:48

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.

查看更多
登录 后发表回答