diff --git a/handlers/dataHandlers.js b/handlers/dataHandlers.js index 3ae90e1..4e45258 100644 --- a/handlers/dataHandlers.js +++ b/handlers/dataHandlers.js @@ -12,6 +12,19 @@ General.find = function(db, collection) { }; }; +General.findWithRegex = function(db, collection) { + return function(req, res, next) { + var query = req.query; + for (let i in query){ + query[i] = new RegExp(query[i], 'i') // case insensitive search + } + mongoDB.find(db, collection, query).then((x) => { + req.data = x; + next(); + }).catch((e) => next(e)); + }; +}; + General.get = function(db, collection) { return function(req, res, next) { var query = req.query;