feat: refs #7524 no apply limit #2921

Merged
jorgep merged 8 commits from 7524-hotfix-addNoLimit into master 2024-09-10 14:48:21 +00:00
1 changed files with 6 additions and 4 deletions
Showing only changes of commit e3b51c81f9 - Show all commits

View File

@ -28,7 +28,7 @@ module.exports = function(Self) {
}); });
this.beforeRemote('**', async ctx => { this.beforeRemote('**', async ctx => {
if (ctx.method.noLimit || !this.hasFilter(ctx)) return; if (!this.hasFilter(ctx)) return;
const defaultLimit = this.app.orm.selectLimit; const defaultLimit = this.app.orm.selectLimit;
const filter = ctx.args.filter || {limit: defaultLimit}; const filter = ctx.args.filter || {limit: defaultLimit};
@ -40,7 +40,7 @@ module.exports = function(Self) {
}); });
this.afterRemote('**', async ctx => { this.afterRemote('**', async ctx => {
if (ctx.method.noLimit || !this.hasFilter(ctx)) return; if (!this.hasFilter(ctx)) return;
const {result} = ctx; const {result} = ctx;
const length = Array.isArray(result) ? result.length : result ? 1 : 0; const length = Array.isArray(result) ? result.length : result ? 1 : 0;
@ -349,8 +349,10 @@ module.exports = function(Self) {
}, },
hasFilter(ctx) { hasFilter(ctx) {
return ctx.req.method.toUpperCase() === 'GET' && const {method, req} = ctx;
ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); if (method.noLimit) return false;
return req.method.toUpperCase() === 'GET' &&
method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object');
}, },
}); });
}; };