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 => {
if (ctx.method.noLimit || !this.hasFilter(ctx)) return;
if (!this.hasFilter(ctx)) return;
juan marked this conversation as resolved Outdated
Outdated
Review

Comprobar ctx.method.noLimit en la función hasFilter para no repetir lógica

Comprobar `ctx.method.noLimit` en la función `hasFilter` para no repetir lógica
const defaultLimit = this.app.orm.selectLimit;
const filter = ctx.args.filter || {limit: defaultLimit};
@ -40,7 +40,7 @@ module.exports = function(Self) {
});
this.afterRemote('**', async ctx => {
if (ctx.method.noLimit || !this.hasFilter(ctx)) return;
if (!this.hasFilter(ctx)) return;
jorgep marked this conversation as resolved Outdated
Outdated
Review

Comprobar ctx.method.noLimit en la función hasFilter para no repetir lógica

Comprobar `ctx.method.noLimit` en la función `hasFilter` para no repetir lógica
const {result} = ctx;
const length = Array.isArray(result) ? result.length : result ? 1 : 0;
@ -349,8 +349,10 @@ module.exports = function(Self) {
},
hasFilter(ctx) {
return ctx.req.method.toUpperCase() === 'GET' &&
ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object');
const {method, req} = ctx;
if (method.noLimit) return false;
return req.method.toUpperCase() === 'GET' &&
method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object');
},
});
};