How create a valid ObjectID in mongodb

Hello!,

How can I create a valid ObjectID to save this in mongodb ?
I need something like this

the red one is what I need, and the green is what I get :
image

I need the id to be generated as mongo does and not created by me, I was trying this :

image

thanks!

I find this solution,

add library js-bson

image

then use it like moment, uuid , lodash, etc

image

1 Like

Hello @sergio_fpay!

Great to hear you found a solution.

As long as the ID just needs to be unique that should work well!