Answers for "string to mongoose objectid"

-1

mongoose id from string

var mongoose = require('mongoose');
var id = mongoose.Types.ObjectId('4edd40c86762e0fb12000003');
Posted by: Guest on November-03-2020
0

mongoose objectid to string

The following example calls the valueOf() method on an ObjectId():

ObjectId("507c7f79bcf86cd7994f6c0e").valueOf()

This will return the following string:

507c7f79bcf86cd7994f6c0e

You can confirm the type of this object using the following operation:

typeof ObjectId("507c7f79bcf86cd7994f6c0e").valueOf()
Posted by: Guest on December-16-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language