summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-02-23 21:01:44 +0200
committerLauri Ojansivu <x@xet7.org>2018-02-23 21:01:44 +0200
commit57cf86a79fe56e89516e9e08746fce217f1c4c98 (patch)
tree0c8dda2fb4ffe2280c1fd48913fea4c4e869e8ff /models
parent1ef663531bb0c52ec37d4132a110c7b8d01561e8 (diff)
parent5bdb392258bd3d3863699e5bf05b64b70f222621 (diff)
downloadwekan-57cf86a79fe56e89516e9e08746fce217f1c4c98.tar.gz
wekan-57cf86a79fe56e89516e9e08746fce217f1c4c98.tar.bz2
wekan-57cf86a79fe56e89516e9e08746fce217f1c4c98.zip
Merge branch 'devel'
Diffstat (limited to 'models')
-rw-r--r--models/boards.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js
index 84a715fb..55b0711c 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -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) {
+ const regex = new RegExp(term, 'i');
+
+ query = {
+ boardId: this._id,
+ $or: [
+ { title: regex },
+ { description: regex },
+ ],
+ };
+ }
+
+ return Cards.find(query, projection);
+ },
});
Boards.mutations({