Global search development

* Add text query ability
* limit results to 50
* display results count
This commit is contained in:
John R. Supplee 2021-01-12 16:48:29 +02:00
parent 34000ad159
commit 2e17f2b4b9
3 changed files with 18 additions and 2 deletions

View file

@ -1798,6 +1798,16 @@ Cards.globalSearch = queryParams => {
}
}
if (queryParams.text) {
const regex = new RegExp(queryParams.text, 'i');
selector.$or = [
{ title: regex },
{ description: regex },
{ customFields: { $elemMatch: { value: regex } } },
];
}
// eslint-disable-next-line no-console
console.log('selector:', selector);
return Cards.find(selector, {
@ -1815,6 +1825,7 @@ Cards.globalSearch = queryParams => {
colors: 1,
dueAt: 1,
},
limit: 50,
});
};