You can do it like so:
var mongoose = require('mongoose');
var id = mongoose.Types.ObjectId('4edd40c86762e0fb12000003');
More Related Contents:
- How to paginate with Mongoose in Node.js?
- mongoDB/mongoose: unique if not null
- Mongoose Unique index not working!
- How do you use Mongoose without defining a schema?
- How to access a preexisting collection with Mongoose?
- How do I query for distinct values in Mongoose?
- MongoDB password with “@” in it
- How to return Mongoose results from the find method?
- MongoDB: output ‘id’ instead of ‘_id’
- How can I update multiple documents in mongoose?
- Mongoose’s find method with $or condition does not work properly
- Delete a key from a MongoDB document using Mongoose
- Can’t find documents searching by ObjectId using Mongoose
- Mongoose, update values in array of objects
- Setting expiry time for a collection in mongodb using mongoose
- MongoDB/Mongoose querying at a specific date?
- How to sort in mongoose?
- Making mongoose.js queries run synchronously
- How to populate a sub-document in mongoose after creating it?
- mongoose custom validation using 2 fields
- (node:3341) DeprecationWarning: Mongoose: mpromise
- MongoDB: how to parse date in 3.6 mongoDb version?
- Mongoose populate nested array
- What is a TransientTransactionError in Mongoose (or MongoDB)?
- is there a mongoose connect error callback
- Mongoose.js instance.save() callback not firing
- How can I generate an ObjectId with mongoose?
- Mongoose – caused by :: 11000 E11000 duplicate key error index?
- Populate a mongoose model with a field that isn’t an id
- MongooseError: Model.findOne() no longer accepts a callback at Function