【发布时间】:2021-06-05 23:14:50
【问题描述】:
我有一个包含注释和用户的数据库。现在我想获取注释内容 = 某物或用户名 = 某物的所有注释。我可以使用 SQL 轻松编写此查询,但无法使用 sequlizer。
Note.findAll({
include: [
{ model: Users, where: { name: 'something' }}
]
})
预期的查询是
select * from users,notes where notes.content='something' or users.name='something'
问题是注释不在包含中,所以我不能使用
where: {
'$or':{
我的问题是如何使用 sequelize 在嵌套表上设置 where 或条件
【问题讨论】:
标签: javascript node.js database postgresql sequelize.js