Permalink
Browse files

added; gt,gte,lt,lte query support for arrays

closes #902
  • Loading branch information...
1 parent f81f4cc commit 68dc94cc3d58fe55dedaeeb34ba565f374879251 @aheckmann aheckmann committed Jun 5, 2012
Showing with 14 additions and 6 deletions.
  1. +14 −6 lib/schema/array.js
View
@@ -156,6 +156,14 @@ SchemaArray.prototype.castForQuery = function ($conditional, val) {
: val;
};
+/**
+ * @ignore
+ */
+
+function castToNumber (val) {
+ return Types.Number.prototype.cast.call(this, val);
+}
+
SchemaArray.prototype.$conditionalHandlers = {
'$all': function handle$all (val) {
if (!Array.isArray(val)) {
@@ -180,23 +188,23 @@ SchemaArray.prototype.$conditionalHandlers = {
query.cast(this.casterConstructor);
return query._conditions;
}
- , '$size': function (val) {
- return ArrayNumberSchema.prototype.cast.call(this, val);
- }
+ , '$size': castToNumber
, '$ne': SchemaArray.prototype.castForQuery
, '$in': SchemaArray.prototype.castForQuery
, '$nin': SchemaArray.prototype.castForQuery
, '$regex': SchemaArray.prototype.castForQuery
, '$near': SchemaArray.prototype.castForQuery
, '$nearSphere': SchemaArray.prototype.castForQuery
+ , '$gt': castToNumber
+ , '$gte': castToNumber
+ , '$lt': castToNumber
+ , '$lte': castToNumber
, '$within': function(val) {
var query = new Query(val);
query.cast(this.casterConstructor)
return query._conditions;
}
- , '$maxDistance': function (val) {
- return ArrayNumberSchema.prototype.cast.call(this, val);
- }
+ , '$maxDistance': castToNumber
};
/**

0 comments on commit 68dc94c

Please sign in to comment.