Open aswathshobi opened 3 years ago
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.
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.
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 it worked for me...
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)
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
getIndex()
, which kinda does the other part of that workflow, that's even more of a bummer..I guess I'll need to build my own index-builder around this now :/