[Sync] Update locally created records with server ids
See original GitHub issueUsing PushChanges with a locally created record uses the id
generated on the client. My server ignores this id
and generates it’s own id
. What’s the recommended way to update the local record with the id
returned from the server? If I don’t update the local id
of the record, it will never receive updates from the server. Thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:27 (6 by maintainers)
Top Results From Across the Web
Sync - WatermelonDB documentation
So a local app can create new records, generating their IDs, and the backend server will use this ID as the true ID....
Read more >Windows Server Update Service (WSUS) to ...
Windows Server Update Service (WSUS) to Microsoft Update sync fails.
Read more >Synchronize Offline Changes with Mobile Sync Unit | Salesforce
The syncUp methods update the server with data from the given SmartStore soup. They look for created, updated, or deleted records in the...
Read more >How to update all properties after store.sync()? - extjs
All records returned from the store after update procedure should replace local ... out that all extjs model fields need to return in...
Read more >How do I synchronize holdings between Alma and WorldCat?
To synchronize local holdings with OCLC by sending MARC Format for Holdings Data (MFHD) records, create a Local Holdings Record Data sync ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, still relevant.
@heliojunior
I have an interface that defines an adapter to handle table changes
Then I have an implementation to handle local id
Assume we have created a local record:
Right before pushing, it will be passed into the
HandleLocalRecordsAdapter.toRemote()
methodThe record is transformed into this:
Then the modified changes will be pushed to the server.
The server just clones the record and generates server-side id for the cloned record.
On the next pulling, the client receives a record like this:
Right after pulling, it will be passed into the
HandleLocalRecordsAdapter.toLocal()
methodThe changes is transformed into this:
The changes is then handled by watermelon db.
If you have multiple models that are related, it is the server to replace the relations with the newly generated server ids. The client data just hooks up automatically.
It’s better to start another synchronize right after the local records are pushed to the server, which is good for consistency.