mirror of
https://github.com/wekan/wekan.git
synced 2025-04-20 12:07:11 -04:00
Add search cards helper to boards model
This commit is contained in:
parent
a9166d877f
commit
2001c01b4d
1 changed files with 21 additions and 0 deletions
|
@ -264,6 +264,27 @@ Boards.helpers({
|
|||
Boards.direct.update(this._id, { $push: { labels: { _id, name, color } } });
|
||||
return _id;
|
||||
},
|
||||
|
||||
searchCards(term) {
|
||||
check(term, Match.OneOf(String, null, undefined));
|
||||
|
||||
let query = { boardId: this._id };
|
||||
const projection = { limit: 10, sort: { createdAt: -1 } };
|
||||
|
||||
if (term) {
|
||||
let regex = new RegExp(term, 'i');
|
||||
|
||||
query = {
|
||||
boardId: this._id,
|
||||
$or: [
|
||||
{ title: regex },
|
||||
{ description: regex },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return Cards.find(query, projection);
|
||||
},
|
||||
});
|
||||
|
||||
Boards.mutations({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue