Merge pull request 'feat: rollback limit' (!2910) from hotfix-rollbackLimit into master
Reviewed-on: #2910 Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
commit
d781a8ab8c
|
@ -27,25 +27,25 @@ module.exports = function(Self) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.beforeRemote('**', async ctx => {
|
// this.beforeRemote('**', async ctx => {
|
||||||
if (!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};
|
||||||
|
|
||||||
if (filter.limit > defaultLimit) {
|
// if (filter.limit > defaultLimit) {
|
||||||
filter.limit = defaultLimit;
|
// filter.limit = defaultLimit;
|
||||||
ctx.args.filter = filter;
|
// ctx.args.filter = filter;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
this.afterRemote('**', async ctx => {
|
// this.afterRemote('**', async ctx => {
|
||||||
if (!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;
|
||||||
if (length >= this.app.orm.selectLimit) throw new UserError('Too many records');
|
// if (length >= this.app.orm.selectLimit) throw new UserError('Too many records');
|
||||||
});
|
// });
|
||||||
|
|
||||||
// Register field ACL validation
|
// Register field ACL validation
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = async function(app) {
|
// module.exports = async function(app) {
|
||||||
if (!app.orm) {
|
// if (!app.orm) {
|
||||||
const ormConfig = await app.models.OrmConfig.findOne();
|
// const ormConfig = await app.models.OrmConfig.findOne();
|
||||||
app.orm = ormConfig;
|
// app.orm = ormConfig;
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
Loading…
Reference in New Issue