#7896 - 24.36 Dev To Test #2884

Merged
jsegarra merged 118 commits from dev into test 2024-08-27 10:32:53 +00:00
1 changed files with 22 additions and 10 deletions
Showing only changes of commit b64b91e50f - Show all commits

View File

@ -28,21 +28,33 @@ module.exports = function(Self) {
};
});
/*
* Intercept GET request for find
*/
this.beforeRemote('find', async ctx => {
isSelect = true;
const filter = ctx.args.filter || {};
if (filter.limit === undefined) {
filter.limit = this.app.orm.selectLimit;
const defaultLimit = this.app.orm.selectLimit;
const filter = ctx.args.filter || {limit: defaultLimit};
if (filter.limit > defaultLimit) {
filter.limit = defaultLimit;
ctx.args.filter = filter;
}
});
this.observe('loaded', async({data}) => {
if (!isSelect) return;
const length = Array.isArray(data) ? data.length : data ? 1 : 0;
this.afterRemote('find', async({result}) => {
const length = Array.isArray(result) ? result.length : result ? 1 : 0;
if (length >= this.app.orm.selectLimit) throw new UserError('Too many records');
});
this.beforeRemote('filter', async ctx => {
const defaultLimit = this.app.orm.selectLimit;
const filter = ctx.args.filter || {limit: defaultLimit};
if (filter.limit > defaultLimit) {
filter.limit = defaultLimit;
ctx.args.filter = filter;
}
});
this.afterRemote('filter', async({result}) => {
const length = Array.isArray(result) ? result.length : result ? 1 : 0;
if (length >= this.app.orm.selectLimit) throw new UserError('Too many records');
});