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!