From fe54b5da1f9ca9fd617d09f762e73df22df7b414 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Thu, 1 Jul 2010 20:40:37 -0400 Subject: [PATCH] Make findAndModify helper function return null rather than {} (no change to server API) --- jstests/find_and_modify.js | 4 ++-- shell/collection.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jstests/find_and_modify.js b/jstests/find_and_modify.js index 5e10079db909a..a80859ab60ca3 100644 --- a/jstests/find_and_modify.js +++ b/jstests/find_and_modify.js @@ -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); diff --git a/shell/collection.js b/shell/collection.js index d97eece8a8e84..1f06a132856ae 100644 --- a/shell/collection.js +++ b/shell/collection.js @@ -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 ); }