Skip to content

Commit

Permalink
added; gt,gte,lt,lte query support for arrays
Browse files Browse the repository at this point in the history
closes #902
  • Loading branch information
aheckmann committed Jun 5, 2012
1 parent f81f4cc commit 68dc94c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/schema/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
};

/**
Expand Down

0 comments on commit 68dc94c

Please sign in to comment.