mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
test case for SERVER-3428
This commit is contained in:
parent
146ef71a17
commit
253f05dfb5
37
jstests/geo_update.js
Normal file
37
jstests/geo_update.js
Normal file
@ -0,0 +1,37 @@
|
||||
// Tests geo queries w/ update & upsert
|
||||
// from SERVER-3428
|
||||
|
||||
var coll = db.testGeoUpdate
|
||||
coll.drop()
|
||||
|
||||
coll.ensureIndex({ loc : "2d" })
|
||||
|
||||
// Test normal update
|
||||
print( "Updating..." )
|
||||
|
||||
coll.insert({ loc : [1.0, 2.0] })
|
||||
|
||||
coll.update({ loc : { $near : [1.0, 2.0] } },
|
||||
{ x : true, loc : [1.0, 2.0] })
|
||||
|
||||
// Test upsert
|
||||
print( "Upserting..." )
|
||||
|
||||
coll.update({ loc : { $within : { $center : [[10, 20], 1] } } },
|
||||
{ x : true },
|
||||
true)
|
||||
|
||||
coll.update({ loc : { $near : [10.0, 20.0], $maxDistance : 1 } },
|
||||
{ x : true },
|
||||
true)
|
||||
|
||||
|
||||
coll.update({ loc : { $near : [100, 100], $maxDistance : 1 } },
|
||||
{ $set : { loc : [100, 100] }, $push : { people : "chris" } },
|
||||
true)
|
||||
|
||||
coll.update({ loc : { $near : [100, 100], $maxDistance : 1 } },
|
||||
{ $set : { loc : [100, 100] }, $push : { people : "john" } },
|
||||
true)
|
||||
|
||||
assert.eq( 4, coll.find().itcount() )
|
Loading…
Reference in New Issue
Block a user