where操作符
async index() { // 拿到数据 let result = {}; let Op = this.app.Sequelize.Op; // 查询多个 result = await this.app.model.User.findAll({ // where 查询条件 where:{ sex:'男', username:{ [Op.like]:"%张三%" }, id:{ [Op.gt]:6 } } }); // 查询多个并统计 // result = await this.app.model.User.findAndCountAll(); this.ctx.body = { msg:'ok', data:result } }
下面是查询出来的数据
感谢大家观看,我们下期见