Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed; $ne works correctly with single vals

  • Loading branch information...
commit 622984b3432d2603b81413dfb927a7b61f16c929 1 parent 6910f46
@aheckmann aheckmann authored
Showing with 11 additions and 4 deletions.
  1. +11 −4 lib/mongoose/query.js
View
15 lib/mongoose/query.js
@@ -190,14 +190,21 @@ Query.prototype.cast = function (model, obj) {
$cond = ks[k];
nested = val[$cond];
- if ('$ne' === $cond && null === nested) {
- continue;
- } else if ('$exists' === $cond) {
+ if ('$ne' === $cond) {
+ if (null === nested) continue;
+ if (!(Array.isArray(nested) || nested.constructor == Object)) {
+ continue;
+ }
+ }
+
+ if ('$exists' === $cond) {
if ('boolean' !== typeof nested) {
throw new Error("$exists parameter must be Boolean");
}
continue;
- } else if ('$not' === $cond) {
+ }
+
+ if ('$not' === $cond) {
this.cast(model, val[$cond]);
} else {
val[$cond] = schematype.castForQuery($cond, nested);
Please sign in to comment.
Something went wrong with that request. Please try again.