mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Changed search to regex (#9575)
* Changed search to regex * Changed to array
This commit is contained in:
@@ -336,7 +336,11 @@ api.getGroups = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (req.query.search) {
|
if (req.query.search) {
|
||||||
filters.$text = { $search: req.query.search };
|
filters.$or = [];
|
||||||
|
const searchWords = req.query.search.split(' ').join('|');
|
||||||
|
const searchQuery = { $regex: new RegExp(`${searchWords}`, 'i') };
|
||||||
|
filters.$or.push({name: searchQuery});
|
||||||
|
filters.$or.push({description: searchQuery});
|
||||||
}
|
}
|
||||||
|
|
||||||
let results = await Group.getGroups({
|
let results = await Group.getGroups({
|
||||||
|
|||||||
Reference in New Issue
Block a user