Skip to content

Commit

Permalink
Stop using err.lastErrorObject (it's not in the driver anymore).
Browse files Browse the repository at this point in the history
  • Loading branch information
sorribas committed Jul 25, 2014
1 parent f487584 commit da252d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}]);
};

Expand Down
12 changes: 1 addition & 11 deletions tests/test-find-and-modify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
Expand Down

0 comments on commit da252d9

Please sign in to comment.