admin管理员组文章数量:1393109
I want to have a copy of my database locally. But on this local copy, I can create new items.
I want the distant database to create item IDs, to avoid duplicate IDs.
So when I create new items, I use temporary IDs on the local database. When I send newly created items to the database using an API, it returns a mapping object between old and new IDs.
In local databases (for instance IndexedDB on web app or SwiftData on my iOS app), ID are unique and can't be edited. So I just create a new object which is a copy of the new one, but with the definitive ID.
Is that a good practice? How are we supposed to sync a local database and a distant database when the local one creates items with temporary IDs?
Thank you very much!
本文标签: Distant and local database synchronization how to manage temporary IDsStack Overflow
版权声明:本文标题:Distant and local database synchronization: how to manage temporary IDs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744654110a2617860.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论