From e621ebc91ceb60e8143f5e2429e861a6b4d63a48 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Thu, 8 Apr 2010 00:08:27 -0400 Subject: [PATCH] sample pull --- jstests/pullall2.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 jstests/pullall2.js diff --git a/jstests/pullall2.js b/jstests/pullall2.js new file mode 100644 index 00000000000..61369badaa4 --- /dev/null +++ b/jstests/pullall2.js @@ -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" );