summaryrefslogtreecommitdiff
path: root/jstests/readonly
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/readonly
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/readonly')
-rw-r--r--jstests/readonly/geo.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/jstests/readonly/geo.js b/jstests/readonly/geo.js
index 13705af0408..2ba43f597b4 100644
--- a/jstests/readonly/geo.js
+++ b/jstests/readonly/geo.js
@@ -30,14 +30,19 @@ runReadOnlyTest(function() {
writableCollection.insertMany(locDocs);
},
exec: function(readableCollection) {
- var res = readableCollection.runCommand({
- geoNear: readableCollection.getName(),
- near: {type: "Point", coordinates: [40.7211404, -73.9591494]},
- spherical: true,
- limit: 1
- });
- assert.commandWorked(res);
- assert.eq(res.results[0].obj.name, "The Counting Room", printjson(res));
+ const res = readableCollection
+ .aggregate([
+ {
+ $geoNear: {
+ near: {type: "Point", coordinates: [40.7211404, -73.9591494]},
+ distanceField: "dist",
+ spherical: true,
+ }
+ },
+ {$limit: 1}
+ ])
+ .toArray();
+ assert.eq(res[0].name, "The Counting Room", printjson(res));
}
};
}());