summaryrefslogtreecommitdiff
path: root/jstests/core/geo_update_dedup.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/geo_update_dedup.js')
-rw-r--r--jstests/core/geo_update_dedup.js35
1 files changed, 21 insertions, 14 deletions
diff --git a/jstests/core/geo_update_dedup.js b/jstests/core/geo_update_dedup.js
index 3011c5c9cfe..b354f3ca7ae 100644
--- a/jstests/core/geo_update_dedup.js
+++ b/jstests/core/geo_update_dedup.js
@@ -7,9 +7,11 @@ var t = db.jstests_geo_update_dedup;
// 2d index with $near
t.drop();
t.ensureIndex({locs: "2d"});
-t.save({locs: [[49.999,49.999], [50.0,50.0], [50.001,50.001]]});
+t.save({locs: [[49.999, 49.999], [50.0, 50.0], [50.001, 50.001]]});
-var q = {locs: {$near: [50.0, 50.0]}};
+var q = {
+ locs: {$near: [50.0, 50.0]}
+};
assert.eq(1, t.find(q).itcount(), 'duplicates returned from query');
var res = t.update({locs: {$near: [50.0, 50.0]}}, {$inc: {touchCount: 1}}, false, true);
@@ -18,8 +20,8 @@ assert.eq(1, t.findOne().touchCount);
t.drop();
t.ensureIndex({locs: "2d"});
-t.save({locs: [{x:49.999,y:49.999}, {x:50.0,y:50.0}, {x:50.001,y:50.001}]});
-res = t.update({locs: {$near: {x:50.0, y:50.0}}}, {$inc: {touchCount: 1}});
+t.save({locs: [{x: 49.999, y: 49.999}, {x: 50.0, y: 50.0}, {x: 50.001, y: 50.001}]});
+res = t.update({locs: {$near: {x: 50.0, y: 50.0}}}, {$inc: {touchCount: 1}});
assert.eq(1, res.nMatched);
assert.eq(1, t.findOne().touchCount);
@@ -35,26 +37,31 @@ assert.eq(1, t.findOne().touchCount);
// 2dsphere index with $geoNear
t.drop();
t.ensureIndex({geo: "2dsphere"});
-var x = { "type" : "Polygon",
- "coordinates" : [[[49.999,49.999], [50.0,50.0], [50.001,50.001], [49.999,49.999]]]};
+var x = {
+ "type": "Polygon",
+ "coordinates": [[[49.999, 49.999], [50.0, 50.0], [50.001, 50.001], [49.999, 49.999]]]
+};
t.save({geo: x});
-res = t.update({geo: {$geoNear: {"type" : "Point", "coordinates" : [50.0, 50.0]}}},
- {$inc: {touchCount: 1}}, false, true);
+res = t.update({geo: {$geoNear: {"type": "Point", "coordinates": [50.0, 50.0]}}},
+ {$inc: {touchCount: 1}},
+ false,
+ true);
assert.eq(1, res.nMatched);
assert.eq(1, t.findOne().touchCount);
t.drop();
var locdata = [
- {geo: {type: "Point", coordinates: [49.999,49.999]}},
- {geo: {type: "Point", coordinates: [50.000,50.000]}},
- {geo: {type: "Point", coordinates: [50.001,50.001]}}
+ {geo: {type: "Point", coordinates: [49.999, 49.999]}},
+ {geo: {type: "Point", coordinates: [50.000, 50.000]}},
+ {geo: {type: "Point", coordinates: [50.001, 50.001]}}
];
t.save({locdata: locdata, count: 0});
t.ensureIndex({"locdata.geo": "2dsphere"});
-res = t.update({"locdata.geo": {$geoNear: {"type" : "Point", "coordinates" : [50.0, 50.0]}}},
- {$inc: {touchCount: 1}}, false, true);
+res = t.update({"locdata.geo": {$geoNear: {"type": "Point", "coordinates": [50.0, 50.0]}}},
+ {$inc: {touchCount: 1}},
+ false,
+ true);
assert.eq(1, res.nMatched);
assert.eq(1, t.findOne().touchCount);
-