From 9878cc8a02a02e79b448f283cd7bd5982dd19069 Mon Sep 17 00:00:00 2001 From: Akalanka Perera Date: Wed, 8 May 2024 12:31:07 +0530 Subject: [PATCH] Feat(filter-query): added support for regexp modifiers --- packages/mongoose-filter-query/src/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/mongoose-filter-query/src/utils.js b/packages/mongoose-filter-query/src/utils.js index 6f418ff..c97a9cf 100644 --- a/packages/mongoose-filter-query/src/utils.js +++ b/packages/mongoose-filter-query/src/utils.js @@ -39,7 +39,8 @@ export const mapValue = (value) => { } else if (value.startsWith("nin(")) { return { $nin: parseOperatorValue(value, "nin").split(",") }; } else if (value.startsWith("reg(")) { - return { $regex: new RegExp(replaceOperator(value, "reg")) }; + const [regex, modifiers] = replaceOperator(value, "reg").split("...[") + return { $regex: new RegExp(regex, modifiers?.slice(0, -1)) }; } else if (value.startsWith("exists(")) { return { $exists: parseOperatorValue(value, "exists") === "true" }; }