feat: add option to change the default value of the Parse.Query.limit() constraint (#8152)
This commit is contained in:
@@ -9,7 +9,7 @@ export class AudiencesRouter extends ClassesRouter {
|
||||
|
||||
handleFind(req) {
|
||||
const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
|
||||
const options = ClassesRouter.optionsFromBody(body);
|
||||
const options = ClassesRouter.optionsFromBody(body, req.config.defaultLimit);
|
||||
|
||||
return rest
|
||||
.find(
|
||||
|
||||
@@ -20,7 +20,7 @@ export class ClassesRouter extends PromiseRouter {
|
||||
|
||||
handleFind(req) {
|
||||
const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
|
||||
const options = ClassesRouter.optionsFromBody(body);
|
||||
const options = ClassesRouter.optionsFromBody(body, req.config.defaultLimit);
|
||||
if (req.config.maxLimit && body.limit > req.config.maxLimit) {
|
||||
// Silently replace the limit on the query with the max configured
|
||||
options.limit = Number(req.config.maxLimit);
|
||||
@@ -149,7 +149,7 @@ export class ClassesRouter extends PromiseRouter {
|
||||
return json;
|
||||
}
|
||||
|
||||
static optionsFromBody(body) {
|
||||
static optionsFromBody(body, defaultLimit) {
|
||||
const allowConstraints = [
|
||||
'skip',
|
||||
'limit',
|
||||
@@ -180,7 +180,7 @@ export class ClassesRouter extends PromiseRouter {
|
||||
if (body.limit || body.limit === 0) {
|
||||
options.limit = Number(body.limit);
|
||||
} else {
|
||||
options.limit = Number(100);
|
||||
options.limit = Number(defaultLimit);
|
||||
}
|
||||
if (body.order) {
|
||||
options.order = String(body.order);
|
||||
|
||||
@@ -11,7 +11,7 @@ export class InstallationsRouter extends ClassesRouter {
|
||||
|
||||
handleFind(req) {
|
||||
const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
|
||||
const options = ClassesRouter.optionsFromBody(body);
|
||||
const options = ClassesRouter.optionsFromBody(body, req.config.defaultLimit);
|
||||
return rest
|
||||
.find(
|
||||
req.config,
|
||||
|
||||
Reference in New Issue
Block a user