Skip to content

Commit

Permalink
Fixed broken behaviour when specifying conditions in Instance.save()
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Jan 12, 2014
1 parent bcdb7c9 commit cb72d9e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,18 @@ Instance.prototype.save = function(conditions, changes, callback) {
/// </signature>

var args = Array.prototype.splice.call(arguments, 0);
conditions = {};
conditions = null;
changes = null;
callback = null;

for(var i = 0; i < args.length; i++) {
if('function' == typeof args[i]) callback = args[i];
else if(!changes) changes = args[i];
else conditions = args[i];
else if(!conditions) conditions = args[i];
else changes = args[i];
}

conditions = conditions || {};

var onError = (function (err) {
this.emit('error', err);
if(callback) return callback(err);
Expand Down

0 comments on commit cb72d9e

Please sign in to comment.