summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-12-07 13:48:29 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-07 14:12:43 +0000
commit5117fe4c17287501311df53d66335026e04a032e (patch)
tree123f2ec6ea9a50ce02e5cc6a2348c6331faff2f0 /jstests
parent7879dd15deaa37f1f3a53a46e9877ef6b03b2f97 (diff)
downloadmongo-5117fe4c17287501311df53d66335026e04a032e.tar.gz
SERVER-61927 clean up geo_circle1_noindex.js
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/geo_circle1_noindex.js30
1 files changed, 19 insertions, 11 deletions
diff --git a/jstests/core/geo_circle1_noindex.js b/jstests/core/geo_circle1_noindex.js
index 6c3135855a5..4e1b8ed9e5f 100644
--- a/jstests/core/geo_circle1_noindex.js
+++ b/jstests/core/geo_circle1_noindex.js
@@ -1,31 +1,39 @@
// SERVER-7343: allow $within without a geo index.
-t = db.geo_circle1_noindex;
+
+(function() {
+'use strict';
+
+const t = db.geo_circle1_noindex;
t.drop();
-searches = [
+const searches = [
[[5, 5], 3],
[[5, 5], 1],
[[5, 5], 5],
[[0, 5], 5],
];
-correct = searches.map(function(z) {
+let correct = searches.map(function(z) {
return [];
});
-num = 0;
+let num = 0;
-for (x = 0; x <= 20; x++) {
- for (y = 0; y <= 20; y++) {
- o = {_id: num++, loc: [x, y]};
- t.save(o);
- for (i = 0; i < searches.length; i++)
+let docs = [];
+for (let x = 0; x <= 20; x++) {
+ for (let y = 0; y <= 20; y++) {
+ const o = {_id: num++, loc: [x, y]};
+ docs.push(o);
+ for (let i = 0; i < searches.length; i++)
if (Geo.distance([x, y], searches[i][0]) <= searches[i][1])
correct[i].push(o);
}
}
+assert.commandWorked(t.insert(docs));
-for (i = 0; i < searches.length; i++) {
- q = {loc: {$within: {$center: searches[i]}}};
+for (let i = 0; i < searches.length; i++) {
+ const q = {loc: {$within: {$center: searches[i]}}};
assert.eq(correct[i].length, t.find(q).itcount(), "itcount : " + tojson(searches[i]));
assert.eq(correct[i].length, t.find(q).count(), "count : " + tojson(searches[i]));
+ assert.eq(correct[i].length, t.countDocuments(q), "aggregation : " + tojson(searches[i]));
}
+})();