feat: refs #7524 no apply limit #2921
|
@ -28,19 +28,19 @@ module.exports = function(Self) {
|
|||
});
|
||||
|
||||
this.beforeRemote('**', async ctx => {
|
||||
if (!this.hasFilter(ctx)) return;
|
||||
if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return;
|
||||
juan marked this conversation as resolved
Outdated
|
||||
|
||||
const defaultLimit = this.app.orm.selectLimit;
|
||||
const filter = ctx.args.filter || {limit: defaultLimit};
|
||||
|
||||
if (filter.limit > defaultLimit) {
|
||||
if (!filter.limit || filter.limit > defaultLimit) {
|
||||
filter.limit = defaultLimit;
|
||||
ctx.args.filter = filter;
|
||||
}
|
||||
});
|
||||
|
||||
this.afterRemote('**', async ctx => {
|
||||
if (!this.hasFilter(ctx)) return;
|
||||
if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return;
|
||||
jorgep marked this conversation as resolved
Outdated
juan
commented
Comprobar 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;
|
||||
|
@ -351,6 +351,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');
|
||||
},
|
||||
|
||||
hasNoLimit(ctx) {
|
||||
return ctx.method.accepts.some(x => x.arg.toLowerCase() === 'nolimit') && ctx.args.noLimit;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -8,6 +8,10 @@ module.exports = Self => {
|
|||
required: true,
|
||||
description: 'Filter defining where and paginated data',
|
||||
http: {source: 'query'}
|
||||
}, {
|
||||
arg: 'noLimit',
|
||||
type: 'Boolean',
|
||||
required: false,
|
||||
}],
|
||||
returns: {
|
||||
type: ['Object'],
|
||||
|
@ -19,7 +23,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getBalance = async(ctx, filter, options) => {
|
||||
Self.getBalance = async(ctx, filter, noLimit, options) => {
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
Loading…
Reference in New Issue
Comprobar
ctx.method.noLimit
en la funciónhasFilter
para no repetir lógica