-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Any method for unique id generator ? #201
Comments
Yea, I'm missing this. When I originally found the lib, I thought that by array support and index searching, it was meant that I could push elements into an array and have them assigned an incrementing id automatically. Since there is also a function I guess I'll need to build my own index-builder around this now :/ |
Maybe it is not suitable for your needs, but with newer Node versions you can generate v4 UUIDs natively with no need for additional packages. Fun fact, even browsers have their own crypto global object with similar functionality. |
Uh, that's nice to hear. One less dependency for me. What I would find more interesting to have is if the library itself would work with uuids or similar internally, without us needing to incorporate somehow. |
Yeah, that would definitely be a nice utility feature to have. |
I found this temporary solution , we can call this function when creating something const ObjectId = (m = Math, d = Date, h = 16, s = s => m.floor(s).toString(h)) =>
s(d.now() / 1000) + ' '.repeat(h).replace(/./g, () => s(m.random() * h)) Like this db.push("/users[]", {
_id: ObjectId(),
username: username
}, true) |
No description provided.
The text was updated successfully, but these errors were encountered: