问题描述
我首先在线查询数据(没有[来自LocalDatastore的查询];)。
并将pin用于本地使用。
为了节省带宽,我使用UpdatedAt来获取新内容。
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. :)
但问题是:如何将本地数据与从Parse仪表板中删除的数据同步?
But the question was: How to sync my local datas with data that are deleted from the Parse dashboard?
例如:获取新内容可以返回零元素,但是,也许它们是在线删除10元素。
Exemple: Getting new stuff can return zero element, But, maybe they are 10 element deleted online.
编辑:最终目标是在解析仪表板中有10000行。并且只抓取更新或删除(而不是所有东西)
The final goal was to have 10000 rows In parse dashboard. And grab only updated or deleted(instead of all stuff)
推荐答案
在这种情况下,我建议不要使用物理删除但是逻辑删除。添加一个名为已删除的新布尔列,当您从设备查询时,您将获得所有数据,如果已删除某些内容,您就会知道它。
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.
您还应该使用名为sync的第二列来指示已删除的行已在本地更新,然后使用后台作业(周期性取决于您的需要)来物理删除这些行。我认为此操作对于安全地清理数据库很重要。如果您将所有已删除的行留在数据库中,则在某些时候您的查询可能会受到速度的影响。
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.
我希望它有所帮助。
Javier。
这篇关于解析。保持LocalDataStore数据同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!