mllm
mllm

Reputation: 17448

How to generate ObjectID in MongoDB

How do I manually generate an ObjectID if I need to insert a document to a MongoDB?

Is it possible to do with shell?

Thanks

Upvotes: 2

Views: 6203

Answers (1)

DanM
DanM

Reputation: 559

Yes it's possible,

Enter mongo shell (type mongo in terminal) and over there simply write:

new ObjectId()

This will return you a new ObjectId as you wish

Upvotes: 7

Related Questions