Skip to content

Commit

Permalink
fix bug where non-changing models would cause all attrs to be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
rschmukler committed Jul 8, 2014
1 parent 3a9dbab commit 91c8df7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module.exports = function(url) {
if(typeof id !== 'object')
id = db.id(id);

if(Object.keys(changed).length == 0) { return cb(null, {}) }
if(Object.keys(changed).length === 0) { return cb(null, this._attrs); }

return db.findAndModify({_id: id}, {}, {$set: changed}, {new: true}, function(err, doc) {
if(err) {
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe("Modella-Mongo", function() {
user.name('Ted');
user.save(function(err) {
expect(err).to.be(null);
expect(user.name()).to.be('Ted');
done();
});
});
Expand Down

0 comments on commit 91c8df7

Please sign in to comment.