summaryrefslogtreecommitdiff
path: root/jstests/upsert1.js
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-06-24 11:24:54 -0400
committerEliot Horowitz <eliot@10gen.com>2010-06-24 11:24:54 -0400
commit1026c72507fb6eb7d2bc16d479d2ec86ac7032cd (patch)
tree0881acc6ee9aa04cdc823e16d4bae668598a34f9 /jstests/upsert1.js
parentf8901bec591369af0a4b4588b3978a5239df657e (diff)
downloadmongo-1026c72507fb6eb7d2bc16d479d2ec86ac7032cd.tar.gz
getLastError has _id of of upserted object SERVER-1173
last error cleaning
Diffstat (limited to 'jstests/upsert1.js')
-rw-r--r--jstests/upsert1.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/jstests/upsert1.js b/jstests/upsert1.js
new file mode 100644
index 00000000000..77cbf57c198
--- /dev/null
+++ b/jstests/upsert1.js
@@ -0,0 +1,14 @@
+
+t = db.upsert1;
+t.drop();
+
+t.update( { x : 1 } , { $inc : { y : 1 } } , true );
+l = db.getLastErrorCmd();
+assert( l.upserted , "A1" );
+assert.eq( l.upserted.str , t.findOne()._id.str , "A2" );
+
+t.update( { x : 2 } , { x : 2 , y : 3 } , true );
+l = db.getLastErrorCmd();
+assert( l.upserted , "B1" );
+assert.eq( l.upserted.str , t.findOne( { x : 2 } )._id.str , "B2" );
+assert.eq( 2 , t.find().count() , "B3" );