0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/apply_ops1.js

24 lines
615 B
JavaScript
Raw Normal View History

2010-06-29 21:22:36 +02:00
t = db.apply_ops1;
t.drop();
assert.eq( 0 , t.find().count() , "A0" );
db.runCommand( { applyOps : [ { "op" : "i" , "ns" : t.getFullName() , "o" : { _id : 5 , x : 17 } } ] } )
assert.eq( 1 , t.find().count() , "A1" );
o = { _id : 5 , x : 17 }
assert.eq( o , t.findOne() , "A2" );
res = db.runCommand( { applyOps : [
{ "op" : "u" , "ns" : t.getFullName() , "o2" : { _id : 5 } , "o" : { $inc : { x : 1 } } } ,
{ "op" : "u" , "ns" : t.getFullName() , "o2" : { _id : 5 } , "o" : { $inc : { x : 1 } } }
] } )
o.x++;
o.x++;
assert.eq( 1 , t.find().count() , "A3" );
assert.eq( o , t.findOne() , "A4" );