This commit is contained in:
parent
c31e33535d
commit
b3b7e9c213
|
@ -31,20 +31,19 @@ module.exports = function(Self) {
|
||||||
/*
|
/*
|
||||||
* Intercept GET request for find
|
* Intercept GET request for find
|
||||||
*/
|
*/
|
||||||
this.beforeRemote('find', async function(ctx) {
|
this.beforeRemote('find', async ctx => {
|
||||||
isSelect = true;
|
isSelect = true;
|
||||||
const filter = ctx.args.filter || {};
|
const filter = ctx.args.filter || {};
|
||||||
// console.log(this.dataSource, Self.dataSource); undefined/null
|
|
||||||
if (filter.limit === undefined) {
|
if (filter.limit === undefined) {
|
||||||
filter.limit = 1/* limit */;
|
filter.limit = this.app.orm.selectLimit;
|
||||||
ctx.args.filter = filter;
|
ctx.args.filter = filter;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.observe('loaded', async function({data}) {
|
this.observe('loaded', async({data}) => {
|
||||||
if (!isSelect) return;
|
if (!isSelect) return;
|
||||||
const length = Array.isArray(data) ? data.length : data ? 1 : 0;
|
const length = Array.isArray(data) ? data.length : data ? 1 : 0;
|
||||||
if (length >= 1) 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
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
module.exports = async function(app) {
|
||||||
|
if (!app.orm) {
|
||||||
|
const ormConfig = await app.models.OrmConfig.findOne();
|
||||||
|
app.orm = ormConfig;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue