diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-05-01 09:30:17 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-05-01 09:30:17 -0400 |
commit | c203325c67046c970030859a557fbe67d04732b1 (patch) | |
tree | ca8dd71c0cb374d5acd3021cc4220e1bf7f0d072 /jstests | |
parent | b1fdaec5363234ed0a8148f579fefc2facf3724a (diff) | |
download | mongo-c203325c67046c970030859a557fbe67d04732b1.tar.gz |
use idhack for _id : { x : 5 } kind of queries
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/idhack.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/jstests/idhack.js b/jstests/idhack.js new file mode 100644 index 00000000000..9614ebcab52 --- /dev/null +++ b/jstests/idhack.js @@ -0,0 +1,23 @@ + +t = db.idhack +t.drop() + + +t.insert( { _id : { x : 1 } , z : 1 } ) +t.insert( { _id : { x : 2 } , z : 2 } ) +t.insert( { _id : { x : 3 } , z : 3 } ) +t.insert( { _id : 1 , z : 4 } ) +t.insert( { _id : 2 , z : 5 } ) +t.insert( { _id : 3 , z : 6 } ) + +assert.eq( 2 , t.findOne( { _id : { x : 2 } } ).z , "A1" ) +assert.eq( 2 , t.find( { _id : { $gte : 2 } } ).count() , "A2" ) +assert.eq( 2 , t.find( { _id : { $gte : 2 } } ).itcount() , "A3" ) + +t.update( { _id : { x : 2 } } , { $set : { z : 7 } } ) +assert.eq( 7 , t.findOne( { _id : { x : 2 } } ).z , "B1" ) + +t.update( { _id : { $gte : 2 } } , { $set : { z : 8 } } , false , true ) +assert.eq( 4 , t.findOne( { _id : 1 } ).z , "C1" ) +assert.eq( 8 , t.findOne( { _id : 2 } ).z , "C2" ) +assert.eq( 8 , t.findOne( { _id : 3 } ).z , "C3" ) |