Details
-
Improvement
-
Resolution: Done
-
Minor - P4
-
None
-
None
-
None
Description
Hello,
recently I created a question in stackoverflow http://stackoverflow.com/questions/19787803/mongo-throws-e11000-duplicate-key-error-whey-i-try-to-do-db-collection-save-oper?noredirect=1#comment29414789_19787803
related to behaviour of function db.collection.save when I try to do insert/replace chunk of documents.
I created the scenario
> use sometestdb
|
switched to db sometestdb
|
>
|
> doc1 = { _id: 1, value: "some value 1" }
|
{ "_id" : 1, "value" : "some value 1" }
|
> doc2 = { _id: 2, value: "some value 2" }
|
{ "_id" : 2, "value" : "some value 2" }
|
> doc3 = { _id: 3, value: "some value 3" }
|
{ "_id" : 3, "value" : "some value 3" }
|
>
|
> db.docs.save( [doc1, doc2, doc3] )
|
>
|
> doc1 = { _id: 1, value: "some value 1 - updated" }
|
{ "_id" : 1, "value" : "some value 1 - updated" }
|
> doc2 = { _id: 2, value: "some value 2 - updated" }
|
{ "_id" : 2, "value" : "some value 2 - updated" }
|
> doc3 = { _id: 3, value: "some value 3 - updated" }
|
{ "_id" : 3, "value" : "some value 3 - updated" }
|
> db.docs.save( [doc1, doc2, doc3] )
|
E11000 duplicate key error index: sometestdb.docs.$_id_ dup key: { : 1.0 }
|
The documentation does no say anything about using array of documents. Is it bug or ambiguous documentation?
Thank you, JM