sequelize的$or操作
A表中有name字段,有关联User表的user_id User表中有个username
现在where时需要A的name模糊查询,和User的username模糊查询,sequelize的$or好像只能对同一张表操作?
1 回复
找到了 http://stackoverflow.com/questions/33271413/sequelize-or-clause-with-multiple-models
options.where = {
$or: [
sequelize.where(sequelize.col('office.name'), { $like: 'foo'}),
sequelize.where(sequelize.col('department.name'), { $like: 'foo'})
]
}