summaryrefslogtreecommitdiff
path: root/jstests/pullall.js
diff options
context:
space:
mode:
authorAaron Staple <aaron@10gen.com>2009-07-21 18:37:30 -0400
committerAaron Staple <aaron@10gen.com>2009-07-21 18:37:30 -0400
commitc477ed3a158354c7f31d950bac6b3a373acc5d1d (patch)
tree7b83e493e4e0533fbd71ce93da7e1e6832939321 /jstests/pullall.js
parent9c44b1c8642dde6d5cb3513728bbfcd235ffe03f (diff)
downloadmongo-c477ed3a158354c7f31d950bac6b3a373acc5d1d.tar.gz
bug SERVER-132 implemented pullAll/pushAll modifiers
Diffstat (limited to 'jstests/pullall.js')
-rw-r--r--jstests/pullall.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/jstests/pullall.js b/jstests/pullall.js
new file mode 100644
index 00000000000..b720ce58204
--- /dev/null
+++ b/jstests/pullall.js
@@ -0,0 +1,18 @@
+t = db.jstests_pushall;
+t.drop();
+
+t.save( { a: [ 1, 2, 3 ] } );
+t.update( {}, { $pullAll: { a: [ 3 ] } } );
+assert.eq( [ 1, 2 ], t.findOne().a );
+t.update( {}, { $pullAll: { a: [ 3 ] } } );
+assert.eq( [ 1, 2 ], t.findOne().a );
+
+t.drop();
+t.save( { a: [ 1, 2, 3 ] } );
+t.update( {}, { $pullAll: { a: [ 2, 3 ] } } );
+assert.eq( [ 1 ], t.findOne().a );
+t.update( {}, { $pullAll: { a: [] } } );
+assert.eq( [ 1 ], t.findOne().a );
+t.update( {}, { $pullAll: { a: [ 1, 5 ] } } );
+assert.eq( [], t.findOne().a );
+