mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
sample pull
This commit is contained in:
parent
c90c179754
commit
e621ebc91c
20
jstests/pullall2.js
Normal file
20
jstests/pullall2.js
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
t = db.pullall2
|
||||
t.drop()
|
||||
|
||||
o = { _id : 1 , a : [] }
|
||||
for ( i=0; i<5; i++ )
|
||||
o.a.push( { x : i , y : i } )
|
||||
|
||||
t.insert( o )
|
||||
|
||||
assert.eq( o , t.findOne() , "A" );
|
||||
|
||||
t.update( {} , { $pull : { a : { x : 3 } } } )
|
||||
o.a = o.a.filter( function(z){ return z.x != 3 } )
|
||||
assert.eq( o , t.findOne() , "B" );
|
||||
|
||||
t.update( {} , { $pull : { a : { x : { $in : [ 1 , 4 ] } } } } );
|
||||
o.a = o.a.filter( function(z){ return z.x != 1 } )
|
||||
o.a = o.a.filter( function(z){ return z.x != 4 } )
|
||||
assert.eq( o , t.findOne() , "C" );
|
Loading…
Reference in New Issue
Block a user