0 votes
1 view
in Web Technology by (42.1k 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 (90.8k 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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...