diff options
Diffstat (limited to 'models/boards.js')
-rw-r--r-- | models/boards.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js index 25cf5e37..530a6f71 100644 --- a/models/boards.js +++ b/models/boards.js @@ -463,6 +463,30 @@ Boards.helpers({ return _id; }, + searchLists(term) { + check(term, Match.OneOf(String, null, undefined)); + + const query = { boardId: this._id }; + if (this.isTemplatesBoard()) { + query.type = 'template-list'; + query.archived = false; + } else { + query.type = {$nin: ['template-list']}; + } + const projection = { limit: 10, sort: { createdAt: -1 } }; + + if (term) { + const regex = new RegExp(term, 'i'); + + query.$or = [ + { title: regex }, + { description: regex }, + ]; + } + + return Lists.find(query, projection); + }, + searchCards(term, excludeLinked) { check(term, Match.OneOf(String, null, undefined)); |