mongodb/node-mongodb-native — pull request #1200 by owenallenaz (2014-08-12 19:11:28+00:00)
Title: Provides fullResult even in an error state which is useful in Bulk inser...

This pull ensures that fullResult is respected at the `writeResult` is available even in the case that an error state has been encountered.

Take the following example for why this matters:

```js
collection.insert([
{ foo : "foo1" },
{ foo : "foo2" },
{ _id : duplicateId, foo : "foo3" },
{ _id : duplicateId2, foo : "foo4" },
{ foo : "foo4" }
], { fullResult : true, keepGoing : true }, function(err, result) {
// do something
});
```

In that case, documents 1,2,5 were successfully inserted into the DB. Documents 3,4 failed. Using the error alone I can't glean this information. But with the `writeResult` available, I can iterate through the writeErrors and reconcile the differences.

In non-keepGoing calls I can use the `err.index` to figure out which docs inserted and which didn't (since it halts at first failure), but I figure that providing the `writeResult` in all cases of `fullResult : true` will make a more consistent API.