diff --git a/common/models/mongo-queryable.js b/common/models/mongo-queryable.js index ae1cb25a..90085986 100644 --- a/common/models/mongo-queryable.js +++ b/common/models/mongo-queryable.js @@ -1,6 +1,7 @@ "use strict"; const utils = require("./utils"); const lodash = require("lodash"); +const escapeStringRegexp = require('escape-string-regexp') module.exports = function (MongoQueryableModel) { // to get access to other models @@ -749,6 +750,23 @@ module.exports = function (MongoQueryableModel) { }); break; } + case "CONTAINS_STRING": { + const escapedRhs = escapeStringRegexp(rhs); + match.$and.push({ + $or: [{ + [matchKeyGeneric]: { + $regex: escapedRhs, + } + }, + { + [`${matchKeyGeneric}.value`]: { + $regex: escapedRhs, + } + } + ] + }); + break; + } case "EQUAL_TO_NUMERIC": { if (unit.length > 0) { const {