Reputation: 1951
I have a very strange issue.
See the code below
const pqr = new ObjectId(smsId);
console.log('pqr', pqr)
docDB.collection(constants.prefix.mongo.COLLECTION_NOTIFICATION)
.findOne(({ "_id": pqr }, (err, notificationDetails) => {
console.log('smsId 3', smsId)
console.log('notificationDetails', notificationDetails) })
below is output
pqr 60986d6210a23dcec4b01e99 // see here
smsId 3 60986d6210a23dcec4b01e99
notificationDetails {
_id: 60986b7e10a23dcec4b01e96, // and here
highPriority: true,.....
I am getting different _id than that of the searched one.
the database is amazon documentDB. client is nodejs client.
what could be the issue?
Upvotes: 1
Views: 155
Reputation: 284
var mongoose = require('mongoose');
const pqr = mongoose.Types.ObjectId(smsId);
Try this once. If you are using Mongoose library.
If you are using Mongodb Library then try this.
const { ObjectId } = require('mongodb');
const pqr = ObjectId(smsId);
Upvotes: 1