diff options
Diffstat (limited to 'jstests/geo_update1.js')
-rw-r--r-- | jstests/geo_update1.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/jstests/geo_update1.js b/jstests/geo_update1.js new file mode 100644 index 0000000..68a8de6 --- /dev/null +++ b/jstests/geo_update1.js @@ -0,0 +1,38 @@ + +t = db.geo_update1 +t.drop() + +for(var x = 0; x < 10; x++ ) { + for(var y = 0; y < 10; y++ ) { + t.insert({"loc": [x, y] , x : x , y : y , z : 1 }); + } +} + +t.ensureIndex( { loc : "2d" } ) + +function p(){ + print( "--------------" ); + for ( var y=0; y<10; y++ ){ + var c = t.find( { y : y } ).sort( { x : 1 } ) + var s = ""; + while ( c.hasNext() ) + s += c.next().z + " "; + print( s ) + } + print( "--------------" ); +} + +p() + +t.update({"loc" : {"$within" : {"$center" : [[5,5], 2]}}}, {'$inc' : { 'z' : 1}}, false, true); +assert.isnull( db.getLastError() , "B1" ) +p() + +t.update({}, {'$inc' : { 'z' : 1}}, false, true); +assert.isnull( db.getLastError() , "B2" ) +p() + + +t.update({"loc" : {"$within" : {"$center" : [[5,5], 2]}}}, {'$inc' : { 'z' : 1}}, false, true); +assert.isnull( db.getLastError() , "B3" ) +p() |