Merge pull request 'revert(salix): rollback limit query' (!2913) from undo_rollback_limit into master
gitea/salix/pipeline/head This commit looks good Details
gitea/salix/pipeline/pr-test This commit looks good Details

Reviewed-on: #2913
Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
This commit is contained in:
Javier Segarra 2024-09-04 08:55:46 +00:00
commit 5f714df73b
2 changed files with 21 additions and 21 deletions

View File

@ -27,25 +27,25 @@ module.exports = function(Self) {
};
});
// this.beforeRemote('**', async ctx => {
// if (!this.hasFilter(ctx)) return;
this.beforeRemote('**', async ctx => {
if (!this.hasFilter(ctx)) return;
// const defaultLimit = this.app.orm.selectLimit;
// const filter = ctx.args.filter || {limit: defaultLimit};
const defaultLimit = this.app.orm.selectLimit;
const filter = ctx.args.filter || {limit: defaultLimit};
// if (filter.limit > defaultLimit) {
// filter.limit = defaultLimit;
// ctx.args.filter = filter;
// }
// });
if (filter.limit > defaultLimit) {
filter.limit = defaultLimit;
ctx.args.filter = filter;
}
});
// this.afterRemote('**', async ctx => {
// if (!this.hasFilter(ctx)) return;
this.afterRemote('**', async ctx => {
if (!this.hasFilter(ctx)) return;
// const {result} = ctx;
// const length = Array.isArray(result) ? result.length : result ? 1 : 0;
// if (length >= this.app.orm.selectLimit) throw new UserError('Too many records');
// });
const {result} = ctx;
const length = Array.isArray(result) ? result.length : result ? 1 : 0;
if (length >= this.app.orm.selectLimit) throw new UserError('Too many records');
});
// Register field ACL validation
/*

View File

@ -1,6 +1,6 @@
// module.exports = async function(app) {
// if (!app.orm) {
// const ormConfig = await app.models.OrmConfig.findOne();
// app.orm = ormConfig;
// }
// };
module.exports = async function(app) {
if (!app.orm) {
const ormConfig = await app.models.OrmConfig.findOne();
app.orm = ormConfig;
}
};