本地删除远程数据
我正在 iPhone 和 Android 上创建两个移动应用程序。 当我更新服务器上的数据时,移动应用程序经常更新其数据库,因此远程和本地数据库之间保持同步。
但是如果用户说删除评论会发生什么?我的本地数据库(移动)中的行将不再更新。
我正在考虑向我的所有实体添加一个删除布尔列,这样我就可以用 returned:true 更新该行,而不是实际删除它,但从用户角度来看,我可以看到这将是一个问题。
解决这个问题的最佳方法是什么? 谢谢 !
编辑:有关它现在如何工作的更多信息:
我的网络服务充当 JSON API。 因此,当我说 /items.json 时,它会为我提供一个按受欢迎程度排序的所有时间前 20 项的数组,然后我可以分页 (/items.json?page=2) 以获取更多数据,或添加类别 (/ items.json?page3&cat=bla)
因此,如果我的本地数据库为空,或者自从您打开应用程序以来已经很长时间了,那么现在的设置方式我基本上会调用 /items.json 。我(目前针对 Android 应用程序)创建一个:INSERT OR REPLACE INTO,以便使用正确的信息添加或更新行。
I am creating two mobile apps, on iPhone and on Android.
As I'm updating data on the server, the mobile apps frequently update their databases and so the sync is kept between the remote and local databases.
But what happens if a user say delete a comment ? The row in my local database (mobile) is just not going to get updated anymore.
I was thinking of maybe adding a delete boolean column to all my entities so that I could just update the row with deleted:true instead of actually deleting it, but user wise I could see how that would be a problem.
What is the best way to fix this problem ?
Thanks !
EDIT : A bit more information on how it works now :
My webservice acts as a JSON API.
So when I say /items.json it gives me an array of the top 20 items of all time sorted by popularity, I can then paginate (/items.json?page=2) to get more data, or add a category (/items.json?page3&cat=bla)
So the way it is setup now I basically call the /items.json if my local DB is empty, or if it has been a long time since you opened the app. And I make (for the Android app for now) an : INSERT OR REPLACE INTO, so that the rows are either added or updated with the right information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
究竟如何保持表同步?有没有办法在移动应用程序中也传输 X 行已被删除并且也应该删除的信息?
How exactly do you keep the tables in sync? Is there no way to also transmit the information that row X has been deleted and should also be deleted in the mobile apps?