### egg扩展 ![](https://img.kancloud.cn/f6/82/f682a538dac68a5032c90a768386b545_983x599.png) ### sequelize 地址:https://www.sequelize.com.cn/ ###利用application扩展方法增加egg-sequelize共同方法 ``` module.exports = { // 将参数传递过来 const { model, args } = self.state CommonService(self) { if (!self.findAndCountAll) { self.findAndCountAll = async (params...) => { const result = await model.findAndCountAll(params...) return result } } } } ``` ### service 构造函数调用application 实现每个service的共同方法 ``` const Service = require('egg').Service class BizVehicleCheckService extends Service { constructor(props) { super(props) props.app.CommonService } } ```