Browse Source

Merge pull request #237 from AMKohn/patch-1

Fixed insert error detection and passing
saintedlama/travis-non-legacy
Christoph Walcher 9 years ago
parent
commit
b8e900e6bc
  1. 3
      lib/collection.js

3
lib/collection.js

@ -81,8 +81,9 @@ Collection.prototype.insert = function (docOrDocs, cb) {
for (var i = 0; i < docs.length; i++) {
if (!docs[i]._id) docs[i]._id = oid()
}
server.insert(self._fullColName(), docs, writeOpts, function (err) {
server.insert(self._fullColName(), docs, writeOpts, function (err, res) {
if (err) return cb(err)
if (res && res.result && res.result.writeErrors && res.result.writeErrors.length > 0) return cb(res.result.writeErrors[0])
cb(null, docOrDocs)
})
})

Loading…
Cancel
Save