I'd like to generate a MongoDB ObjectId with Mongoose. Is there a way to access the ObjectId constructor from Mongoose?
This question is about generating a new
ObjectIdfrom scratch. The generated ID is a brand new universally unique ID.Another question asks about creating an
ObjectIdfrom an existing string representation. In this case, you already have a string representation of an ID—it may or may not be universally unique—and you are parsing it into anObjectId.