I am getting this error while trying to insert data in the MongoDB collection.
MongoError: E11000 duplicate key error collection: kaa.logs_96775772132708234336 index: id dup key: { _id: ObjectId('6001bdc2429b9313d755e106') }
Here is my code :
MongoClient.connect(url, function(err, db) { if (err) throw err; var dbo = db.db("kaa"); dbo.collection("logs_96775772132708234336").insertOne(document, function(err, res) { if (err) throw err; console.log("1 document inserted"); console.log(res.insertedId); db.close(); }); }); When I am searching for the same object id, I am getting data. It seems NodejS Mongo is creating a duplicate object ID.
Any help is much appreciated.
https://stackoverflow.com/questions/65739720/mongodb-duplicate-key-erro January 16, 2021 at 12:22AM
没有评论:
发表评论