Skip to content

Commit

Permalink
fix(geospatial): use correct context for castToNumber
Browse files Browse the repository at this point in the history
Re: #6893
  • Loading branch information
vkarpov15 committed Aug 25, 2018
1 parent 8b2a499 commit 3b99dbd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/schema/operators/geospatial.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ function cast$within(val) {

if (val.$box || val.$polygon) {
var type = val.$box ? '$box' : '$polygon';
val[type].forEach(function(arr) {
val[type].forEach(arr => {
if (!Array.isArray(arr)) {
const msg = 'Invalid $within $box argument. '
+ 'Expected an array, received ' + arr;
throw new TypeError(msg);
}
arr.forEach(function(v, i) {
arr.forEach((v, i) => {
arr[i] = castToNumber.call(this, v);
});
});
} else if (val.$center || val.$centerSphere) {
type = val.$center ? '$center' : '$centerSphere';
val[type].forEach(function(item, i) {
val[type].forEach((item, i) => {
if (Array.isArray(item)) {
item.forEach(function(v, j) {
item.forEach((v, j) => {
item[j] = castToNumber.call(this, v);
});
} else {
Expand Down

0 comments on commit 3b99dbd

Please sign in to comment.