How can I define structure of local IDs?
See original GitHub issueHow could I add prefix or postfix on local ID which was generated automatically before being sent to sync server?
In my case:
- every one would register an account on our server, and the identification, with a unique account ID, would be saved in local database after first signing in;
- client data would be saved separately into their local database firstly. In my mind, I thought that local IDs would be generated locally and WatermelonDB would try to keep it to be unique locally, right? That means it might not be unique on the remote server.
- I would like to prefix or postfix the identification ID to each local ID before sending them to the remote server to avoid the not-unique-remotely issue, and it also could be used for sharding easily on the remote database.
pseudo-code for transforming local ID:
global.identification = {
id: 12345,
name: 'myFirstPet'
};
function transformId(item: Model) {
return global.identification.id + '-' + item._raw_id;
}
But I did not find any comment about postfixing or prefixing on local ID, could you please help me to resolve it?
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
5.1 Defining Structure Types: struct - Racket Documentation
A struct form with n fields defines up to 4+2n names: struct:id, a structure type descriptor value that represents the structure type.
Read more >What are Data Structures? - Definition from WhatIs.com
A data structure is a specialized format for organizing, processing, retrieving and storing data. There are several basic and advanced types of data ......
Read more >Series ID Formats - Bureau of Labor Statistics
Survey Overview The following is a sample format description of the Local Area Unemployment Statistics' series identifier:
Read more >database - Assigning a local id to a user
A local ID is local to the user but global in the user space, i.e. for every interaction between users the same local...
Read more >StructureDefinition - FHIR v5.0.0-snapshot3
Multiple keywords may be assigned to the structure. These may either describe the structure, the focus of the structure or both. They are...
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
@netbull this was discussed in other issues already. Getting a conflict on a random ID is very, very unlikely. You can absolutely do sync-time ID remapping, but it’s a huge pain in the butt when you have relations between objects.
Indeed, you can add this 😃 You can send a quick PR to the docs from the browser: https://github.com/Nozbe/WatermelonDB/blob/master/docs-master/Advanced/Sync.md
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.