what is objectid in mongodb
var ObjectId = require('mongodb').ObjectID
var id = new ObjectId();
console.log(id)
what is objectid in mongodb
var ObjectId = require('mongodb').ObjectID
var id = new ObjectId();
console.log(id)
mongo query by object id node js
//declare ObjectId from mongodb module
const ObjectId = require('mongodb').ObjectId;
//transform your param into an ObjectId
var id = req.params.id;
var good_id = new ObjectId(id);
//you can now query
Model.find({_id: good_id})
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us