Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
canstudios-nicolaw committed Jun 12, 2019
1 parent 2a3fbdd commit b130810
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/content/course/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ function doQuery(req, res, andOptions, next) {
andOptions = [];
}
const options = Object.assign({}, req.body, req.query);
options.search = Object.assign({}, req.body.search, req.query.search);
const search = options.search || {};
const self = this;
const orList = [];
const andList = [];
// convert searches to regex
async.each(Object.keys(search), function (key, nextKey) {
if ('string' === typeof search[key]) { // string -> regex
// Convert string -> regex, special case $or should be within $and
if ('string' === typeof search[key] && key !== "$or") {
orList.push({ [key]: new RegExp(search[key], 'i') });
} else {
andList.push({ [key]: search[key] });
Expand Down

0 comments on commit b130810

Please sign in to comment.