diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 6fcb6f0e3..a11bed11d 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -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 /* diff --git a/loopback/server/boot/orm.js b/loopback/server/boot/orm.js index ccd9d4eca..8bbd969e1 100644 --- a/loopback/server/boot/orm.js +++ b/loopback/server/boot/orm.js @@ -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; + } +};