-
|
I want to delegate the generation of IDs to my backend (to avoid conflicts when using multiple client devices, also I have a legacy backend data that already has IDs generated).
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
This is possible, but it isn't a good idea if you have other options. Since SignalDB is a local-first database, it must be able to generate IDs on its own. What you could do is map the backend ID to a field in your document (let's call it If a document doesn't have a I don't recommend this approach, as it makes it difficult to verify which documents were already created in your backend. This can lead to duplicate entries. Only use this method if you cannot modify your backend's API. If you're able to make changes to your backend, consider one of these better alternatives:
|
Beta Was this translation helpful? Give feedback.
This is possible, but it isn't a good idea if you have other options.
Since SignalDB is a local-first database, it must be able to generate IDs on its own. What you could do is map the backend ID to a field in your document (let's call it
remote_id) during the pull operation. During thepush, you need to map it back and discard the ID generated by SignalDB before making calls to your backend.If a document doesn't have a
remote_idset, create it in the backend. Otherwise, update the existing record.I don't recommend this approach, as it makes it difficult to verify which documents were already created in your backend. This can lead to duplicate entries. Only use this method if you cannot…