Files
mongo/jstests/core/geo_update2.js
Randolph Tan 5595b94560 SERVER-12127 migrate js tests to jscore suite when not related to writes
Moved test jstest/[a-i].js -> jstests/core/ and made changes to comply with write command api
2014-02-28 16:26:33 -05:00

40 lines
831 B
JavaScript

t = db.geo_update2
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 });
}
}
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()
assert.writeOK(t.update({"loc" : {"$within" : {"$center" : [[5,5], 2]}}},
{'$inc' : { 'z' : 1}}, false, true));
p()
assert.writeOK(t.update({}, {'$inc' : { 'z' : 1}}, false, true));
p()
assert.writeOK(t.update({"loc" : {"$within" : {"$center" : [[5,5], 2]}}},
{'$inc' : { 'z' : 1}}, false, true));
p()