How To Properly Cast Objectid In Mongoose
I'm running into some issues with casting ObjectId in express.js using mongoose. In my route i have tried both casting before as well as just using the req.params.id directly. Noth
Solution 1:
It seems as soon as you post on SO you will find the answer yourself, so here goes.
This function will effectively cast a string to an ObjectId: mongoose.Types.ObjectId(req.params.id);
Post a Comment for "How To Properly Cast Objectid In Mongoose"