|
The bulkWrite command should return an numErrors field indicating the number of errors in its cursor response. So this will look something like:
{
|
ok: 1,
|
numErrors: NumberInt(...),
|
cursor: {
|
id: NumberLong(...),
|
firstBatch: [
|
{ ok: 1, idx: 0, n: NumberInt(...), nModified: NumberInt(...), upserted: any, value: { ... } },
|
{ ok: 0, idx: 1, code: NumberInt(...), codeName: " ... ", errmsg: " ... " },
|
...
|
]
|
},
|
...
|
}
|
Based on the numErrors, users can decide if they would like to iterate through the cursor responses to consume the response for each individual operation. If the users/drivers decide not to exhaust the returned cursor, it is expected that a killCursors command is sent to kill the cursor on the server side.
Note this ticket also covers updating existing tests in jstests/core/write/bulk/bulk_write_*_cursor.js to properly test the number of errors returned and add any new required tests to cover multiple errors being counted correctly.
|