Parse. Keep LocalDataStore data sync

☆樱花仙子☆ 提交于 2019-11-29 16:32: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. :)



来源:https://stackoverflow.com/questions/29323192/parse-keep-localdatastore-data-sync

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!