sequelize中在[Op.or]使用[Op.like] 使用情况:sequelize一个搜索值模糊查询表的两个列 'use strict'; const Service = require('egg').Service; const Op = this.ctx.model.Sequelize.Op; class UserService extends Service { async list(username, page, limit){ let where = {}; if (username != '') { where = { [Op.or]: [{ nickname: { [Op.like]: '%' + username + '%' } }, //like和or连用 { username: { [Op.like]: '%' + username + '%' } }, ], }; } return await this.ctx.model.user.findAndCountAll({ where, offset: (parseInt(params.page) - 1) * parseInt(params.limit), // 每页起始位置 limit: parseInt(params.limit), order: [[ 'last_login_time', 'DESC' ]], //排序 include: [ //连表查询 { model: this.ctx.model.UserInfo, attributes: [[ 'user_level', 'user_level'],], }, ], }); } } module.exports = UserService;