-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot provide my own id #2
Comments
Related with the PR #3 |
@jblandino Do you think it is common to provide an ID on creation? If that's the case I'm open to consider allowing users to provide id on creation. As you mentioned, I think it would be also good to allow user to provide a function for id generation. That way, user can opt-in for any kind of identity generator. What are your thoughts? |
Hi @rmariuzzo. Well if you knew that when I implemented it in a project that I currently have, the first thing I did was send some session data to see how I could store them temporarily but send these fields: { id: Number, _token: String, date: Date } The ID is a value that I generate in my own application and for me that field is mandatory, it happens that when I save it I realize that lowdb replaces it with its own identifier automatically. This need was that it led me to think that it would be good to leave the resource identifier outside the object where the user's data is stored.
|
@jblandino in that case I'm willing to allow user to provide their id. The flow will be:
What do you think? I'm open to suggestions. |
Perfect @rmariuzzo , if the user passes his own ID he could use it and in case he does not pass it then the autogenerate is used, I see it well. |
The structure you use to save the resources automatically generates an incremental ID, in which case you want to save this:
I simply omit the ID field since I would try to replace the one generated by lowdb-api.
One suggestion would be that instead of an incremental ID you generate a kind of {_id: guid_format} (or any unique data) or have the identifier inside protected object:
The text was updated successfully, but these errors were encountered: