Skip to content

Commit

Permalink
add findwithregex
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Aug 21, 2023
1 parent d00afd8 commit 2e7a88a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions handlers/dataHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){

Check failure on line 18 in handlers/dataHandlers.js

View workflow job for this annotation

GitHub Actions / build (18.x)

The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype

Check failure on line 18 in handlers/dataHandlers.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing space before opening brace

Check failure on line 18 in handlers/dataHandlers.js

View workflow job for this annotation

GitHub Actions / build (20.x)

The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype

Check failure on line 18 in handlers/dataHandlers.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Missing space before opening brace
query[i] = new RegExp(query[i], 'i') // case insensitive search

Check failure on line 19 in handlers/dataHandlers.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing semicolon

Check failure on line 19 in handlers/dataHandlers.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Missing semicolon
}
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;
Expand Down

0 comments on commit 2e7a88a

Please sign in to comment.