diff --git a/client/components/main/globalSearch.js b/client/components/main/globalSearch.js index 526f744b6..1866caf2c 100644 --- a/client/components/main/globalSearch.js +++ b/client/components/main/globalSearch.js @@ -227,6 +227,7 @@ BlazeComponent.extendComponent({ 'operator-comment': 'comments', 'operator-has': 'has', 'operator-sort': 'sort', + 'operator-limit': 'limit', }; const predicates = { @@ -430,6 +431,16 @@ BlazeComponent.extendComponent({ } else { value = predicateTranslations.has[value]; } + } else if (operator === 'limit') { + const limit = parseInt(value, 10); + if (isNaN(limit) || limit < 1) { + this.parsingErrors.push({ + tag: 'operator-limit-invalid', + value, + }); + } else { + value = limit; + } } if (Array.isArray(params[operator])) { params[operator].push(value); diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index e1710db94..348a29fea 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -907,6 +907,7 @@ "operator-sort": "sort", "operator-comment": "comment", "operator-has": "has", + "operator-limit": "limit", "predicate-archived": "archived", "predicate-ended": "ended", "predicate-all": "all", @@ -928,6 +929,7 @@ "operator-sort-invalid": "sort of '%s' is invalid", "operator-status-invalid": "'%s' is not a valid status", "operator-has-invalid": "%s is not a valid existence check", + "operator-limit-invalid": "%s is not a valid limit. Limit should be a positive integer.", "next-page": "Next Page", "previous-page": "Previous Page", "heading-notes": "Notes", diff --git a/server/publications/cards.js b/server/publications/cards.js index 06c90b5e3..d4737851b 100644 --- a/server/publications/cards.js +++ b/server/publications/cards.js @@ -755,13 +755,14 @@ function findCards(sessionId, selector, projection, errors = null) { // check(projection, Object); const userId = Meteor.userId(); + console.log('selector:', selector); + console.log('projection:', projection); + let cards; if (!errors || !errors.hasErrors()) { cards = Cards.find(selector, projection); } - console.log('selector:', selector); - console.log('projection:', projection); console.log('count:', cards.count()); const update = { $set: {