I am using mongojs and Node.js to insert a document in mongodb. It is a REST API and there is only one instance of mongojs (with native drive). Everytime, there is an api call, SAME mongojs object is used to perform mongodb operations. Now, I get the following error when trying to insert a document.
{
name: "MongoError"
err: "E11000 duplicate key error index: testdb.userComment.$_id_ dup key: { : ObjectId('51727190bb4ab52a80024c09') }"
code: 11000
n: 0
connectionId: 225
ok: 1
}
The document is always unique
I tried db.userComment.getIndexs()
and it shows the index is on _id . Can anyone help me how I can fix this problem ?