Skip to content
This repository has been archived by the owner on Oct 7, 2023. It is now read-only.

Commit

Permalink
Support and tests added for $nottypeof queries
Browse files Browse the repository at this point in the history
  • Loading branch information
sri-rang committed Aug 7, 2012
1 parent 58e24c2 commit 501dde2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions browserdb.js
Expand Up @@ -102,6 +102,9 @@
case '$typeof':
operation = typeof object[clause] === value;
break;
case '$nottypeof':
operation = typeof object[clause] !== value;
break;
}
if (!operation) return false;
}
Expand Down
9 changes: 8 additions & 1 deletion test/find.js
Expand Up @@ -12,7 +12,7 @@ new BrowserDb({

browserDb.books.save({
__id:2,
topic:["android"],
topic:"android",
title:"Android in action",
cost:100
});
Expand Down Expand Up @@ -121,4 +121,11 @@ new BrowserDb({
});
});

browserDb.books.find({topic:{$nottypeof:"object"}}, function (error, books) {
test("Find where topic is not an array", function () {
deepEqual(books.length, 1, "One book");
deepEqual(books[0].__id, 2, "book __id must be 2");
});
});

});

0 comments on commit 501dde2

Please sign in to comment.