Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (50.2k points)

I want to create a MongoDB ObjectId with the help of Mongoose. Can we access the ObjectId constructor from Mongoose?

1 Answer

0 votes
by (108k points)

For finding the ObjectId constructor on require('mongoose').Types refer to the following code:

var mongoose = require('mongoose');

var id = mongoose.Types.ObjectId();

The variable id is a newly created ObjectId using mongoose.

If you are a beginner and want to know more about MongoDB then refer to the following MongoDB tutorial which will help you to learn MongoDB from scratch.

Related questions

Browse Categories

...