diff --git a/common.coffee b/common.coffee index d468f1b..c679045 100644 --- a/common.coffee +++ b/common.coffee @@ -79,5 +79,6 @@ exports.NUMBER_TYPE = NUMBER_TYPE exports.STRING_TYPE = STRING_TYPE exports.ARRAY_TYPE = ARRAY_TYPE exports.OBJECT_TYPE = OBJECT_TYPE +exports.REGEXP_TYPE = REGEXP_TYPE exports.typeOf = typeOf diff --git a/mongo-query.coffee b/mongo-query.coffee index 40a3b2a..e06cd2d 100644 --- a/mongo-query.coffee +++ b/mongo-query.coffee @@ -9,10 +9,14 @@ test = (obj, query) -> value = common.getParamValueFromPath(obj, k) if common.typeOf(v) isnt common.OBJECT_TYPE + # TODO comparing array to regex, array to array, and object to object if common.typeOf(value) is common.ARRAY_TYPE res = value.indexOf(v) != -1 else - res = v == value + if common.typeOf(v) is common.REGEXP_TYPE + res = v.test(value) + else + res = v == value else for k2,v2 of v switch k2