Skip to content

Commit

Permalink
fix(query): cast $not objects
Browse files Browse the repository at this point in the history
Fix #4495
  • Loading branch information
vkarpov15 committed Sep 30, 2016
1 parent 57bee9f commit 154b2c9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var ALLOWED_GEOWITHIN_GEOJSON_TYPES = ['Polygon', 'MultiPolygon'];
module.exports = function cast(schema, obj) {
var paths = Object.keys(obj),
i = paths.length,
_keys,
any$conditionals,
schematype,
nested,
Expand Down Expand Up @@ -203,6 +204,17 @@ module.exports = function cast(schema, obj) {
}

if ($cond === '$not') {
if (nested && schematype && !schematype.caster) {
_keys = Object.keys(nested);
if (_keys.length && _keys[0].charAt(0) === '$') {
for (var key in nested) {
nested[key] = schematype.castForQuery(key, nested[key]);
}
} else {
val[$cond] = schematype.castForQuery($cond, nested);
}
continue;
}
cast(schematype.caster ? schematype.caster.schema : schema, nested);
} else {
val[$cond] = schematype.castForQuery($cond, nested);
Expand Down

1 comment on commit 154b2c9

@KATT
Copy link

@KATT KATT commented on 154b2c9 Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.