Browse Source

Stop using err.lastErrorObject (it's not in the driver anymore).

saintedlama/travis-non-legacy
Eduardo Sorribas 10 years ago
parent
commit
da252d98e2
  1. 2
      index.js
  2. 12
      tests/test-find-and-modify.js

2
index.js

@ -214,7 +214,7 @@ Collection.prototype.findAndModify = function(options, callback) {
// property is added to the err argument instead.
// If the findAndModify command finds no matching document, when performing update or remove,
// no lastErrorObject is included (so we fake it).
(callback || noop)(err, doc, (err && err.lastErrorObject) || (obj && obj.lastErrorObject) || { n: 0 });
(callback || noop)(err, doc, (obj && obj.lastErrorObject) || { n: 0 });
}]);
};

12
tests/test-find-and-modify.js

@ -63,17 +63,7 @@ insert([{
assert.ok(!err);
assert.equal(lastErrorObject.n, 0);
// Correct error handling
db.a.findAndModify({
update: { $illigal: 1 }
}, function(err, doc, lastErrorObject) {
assert(err instanceof Error);
assert.equal(doc, null);
assert.equal(lastErrorObject.n, 0);
assert.equal(typeof lastErrorObject.err, 'string');
done();
});
done();
});
});
});

Loading…
Cancel
Save