Merge pull request #4984 from mfilser/global_search_limit_0_is_no_limit

Global Search, limit 0 is no limit
This commit is contained in:
Lauri Ojansivu 2023-06-28 15:54:34 -04:00 committed by GitHub
commit 9130410f09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -540,12 +540,15 @@ export class Query {
}
} else if (operator === OPERATOR_LIMIT) {
const limit = parseInt(value, 10);
if (isNaN(limit) || limit < 1) {
if (isNaN(limit) || limit < 0) {
this.addError(OPERATOR_LIMIT, {
tag: 'operator-limit-invalid',
value,
});
continue;
} else if (limit == 0) {
// no limit
continue;
} else {
value = limit;
}

View file

@ -562,8 +562,10 @@ function buildProjection(query) {
sort: 1,
},
skip,
limit,
};
if (limit > 0) {
projection.limit = limit;
}
if (query.getQueryParams().hasOperator(OPERATOR_SORT)) {
const order =