Skip to content

Commit

Permalink
Make findAndModify helper function return null rather than {} (no cha…
Browse files Browse the repository at this point in the history
…nge to server API)
  • Loading branch information
RedBeard0531 committed Jul 2, 2010
1 parent 224ca4a commit fe54b5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions jstests/find_and_modify.js
Expand Up @@ -33,6 +33,6 @@ assert.eq(out.priority, 1);
out = t.findAndModify({sort:{priority:1}, remove:1});
assert.eq(out.priority, 2);

// return empty obj if no matches (drivers may handle this differently)
// return null (was {} before 1.5.4) if no matches (drivers may handle this differently)
out = t.findAndModify({query:{no_such_field:1}, remove:1});
assert.eq(out, {});
assert.eq(out, null);
2 changes: 1 addition & 1 deletion shell/collection.js
Expand Up @@ -337,7 +337,7 @@ DBCollection.prototype.findAndModify = function(args){
var ret = this._db.runCommand( cmd );
if ( ! ret.ok ){
if (ret.errmsg == "No matching object found"){
return {};
return null;
}
throw "findAndModifyFailed failed: " + tojson( ret.errmsg );
}
Expand Down

0 comments on commit fe54b5d

Please sign in to comment.