-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Currently we don't return the number of docs inserted, or the number that error'd out, or, in the continueOnError case, a list of errors.
> db.test1.insert([{_id:1}, {_id:1}, {_id:1}]); db.getLastErrorObj() { "err" : "E11000 duplicate key error index: github.test1.$_id_ dup key: { : 1.0 }", "code" : 11000, "n" : 0, "connectionId" : 1, "ok" : 1 }
We should set "n" to successful docs inserted, and nFailures to the number of failed insertions (1 if continueOnError is false).
In addition we should return an errorDocs field like this:
errorDocs: [ {_id:1, err:"..."}, {_id:1, err:"..."}, {_id:1, err:"..."}, ]
So the client will know which docs failed on the insert.
- is duplicated by
-
SERVER-4381 getLastError returns n:0 after insert, always
- Closed
- is related to
-
SERVER-1699 Fill in _id value for inserted docs
- Closed
- related to
-
SERVER-9038 New write operation method for insert, update, remove
- Closed