vasern / vasern

Vasern is a fast, lightweight and open source data storage for React Native

Home Page:https://vasern.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Customisable id

apppro123 opened this issue · comments

Is it possible to make own ids (otherwise i would just overwrite the id with my own one and save the last id with async storage)? Because i would need ascending ids, so i know that every id is only once used and 100% unique!

At the moment, this version haven’t support custom ID field yet. Though auto generated ids are highly unique.

In the ID contains different “meaningful” variables and numbers (encoded to characters), which include:

(1). Time in seconds counting from 1/1/1970
(2). A number starting from 0, if the multile ids generated in the same (1), this number will be automatically increase.
(3). 5 random characters to ensure even (2) is repeated, it still generates a different id.

Besides, the ID also design to ensure uniqueness incase it is sync to multiple devices.

Int ID is not preferable as in case it need to sync to another device, it will cause issues with duplicates id.

By the way, there is no way to generate ID that is 100% unique. Any ID generator techniques are trying to make it super hard to duplicate.

So you don’t really to worry about the ID uniqueness.

Is there any other reason that you need an integer id? I’ll see if I can help!

But if i make an id that always increase for one db than it shouldn't be possible to have same ids.
And this id generator makes a lot of sense if with sessions and online using. But just for calendar events for one user it is totally fine if i have ascending ids.
Maybe it would be useful if it is possible to give and id: "string"/"int" property and if this is given it doesnt generate an extra id. If there is no id property it does.
Thank you for your help!

No worries. It does makes sense to me that customisable IDs is more preferable.