From 1ff1a97f29e9638fddabb1bbaa6fc3d539d815d4 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 13:21:56 +0200 Subject: [PATCH] feat: refs #7524 check noLimit method key --- loopback/common/models/vn-model.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 269ed673d..596ec0967 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,7 +28,7 @@ module.exports = function(Self) { }); this.beforeRemote('**', async ctx => { - if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; + if (ctx.method.noLimit || !this.hasFilter(ctx)) return; 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 (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; + if (ctx.method.noLimit || !this.hasFilter(ctx)) return; const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; @@ -352,10 +352,5 @@ module.exports = function(Self) { 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; - } - }); };