summaryrefslogtreecommitdiff
path: root/jstests/core/geod.js
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2018-06-18 23:34:49 -0400
committerKyle Suarez <kyle.suarez@mongodb.com>2018-06-18 23:34:49 -0400
commit7bc7864fc042b69d36a88c6839c5dd5b4eb20693 (patch)
treee103e752e5d708aa22dca3ae99ef269d79a5d917 /jstests/core/geod.js
parent7c89f48c4f1f1e3ede2931ab602fa118281530a2 (diff)
downloadmongo-7bc7864fc042b69d36a88c6839c5dd5b4eb20693.tar.gz
SERVER-35043, SERVER-22949: move geoNear implementation into aggregation
This commit removes the geoNear command and moves its implementation into the aggregation framework. Users should use the aggregate command with a $geoNear stage. The implementation rewrite additionally removes the limit in the $geoNear aggregation stage. To limit the number of results, use a $limit stage.
Diffstat (limited to 'jstests/core/geod.js')
-rw-r--r--jstests/core/geod.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/jstests/core/geod.js b/jstests/core/geod.js
index 35844d0f914..055453254a5 100644
--- a/jstests/core/geod.js
+++ b/jstests/core/geod.js
@@ -7,8 +7,11 @@ t.ensureIndex({loc: "2d"});
// should match no points in the dataset.
dists = [.49, .51, 1.0];
for (idx in dists) {
- b = db.runCommand({geoNear: "geod", near: [1, 0], num: 2, maxDistance: dists[idx]});
- assert.eq(b.errmsg, undefined, "A" + idx);
- l = b.results.length;
- assert.eq(l, idx, "B" + idx);
+ b = db.geod
+ .aggregate([
+ {$geoNear: {near: [1, 0], distanceField: "d", maxDistance: dists[idx]}},
+ {$limit: 2},
+ ])
+ .toArray();
+ assert.eq(b.length, idx, "B" + idx);
}