Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7033

Provide details about successes and errors in bulk insert in getLastError

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: