Add new has operator for searching

This commit is contained in:
John R. Supplee 2021-02-21 01:41:58 +02:00
parent c02b71e0e1
commit 726be664c8
4 changed files with 43 additions and 2 deletions

View file

@ -507,6 +507,20 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
});
}
if (queryParams.has.length) {
queryParams.has.forEach(has => {
if (has === 'description') {
selector.description = { $exists: true, $nin: [null, ''] };
} else if (has === 'attachment') {
const attachments = Attachments.find({}, { fields: { cardId: 1 } });
selector.$and.push({ _id: { $in: attachments.map(a => a.cardId) } });
} else if (has === 'checklist') {
const checklists = Checklists.find({}, { fields: { cardId: 1 } });
selector.$and.push({ _id: { $in: checklists.map(a => a.cardId) } });
}
});
}
if (queryParams.text) {
const regex = new RegExp(escapeForRegex(queryParams.text), 'i');