mysql - 如何在 Sequelize 和 Mysql 中编写此查询

标签 mysql node.js sequelize.js

我不知道如何在 Sequelize 中编写这种类型的查询。
SELECT * FROM messages WHERE (senderId=324 AND receiverId=340) OR (receiverId=324 AND senderId = 340) AND documentSetId=585;

最佳答案

这是你要找的吗?

YourModel.findAll({
            where: {
                documentSetId: 585,
                $or: [
                    {
                        senderId: 324,
                        receiverId: 340,
                    }, {
                        senderId: 340,
                        receiverId: 324,
                    },
                ],
            },
        })

关于mysql - 如何在 Sequelize 和 Mysql 中编写此查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60149278/

相关文章:

node.js - 为什么我的流媒体应用程序没有完全显示图像?

node.js - 在 promise.then 中返回值

Java 运行时执行 SQL 脚本在 SQL 错误时继续

mysql - 选择用户未观看的所有电影并将结果限制为 20

javascript - node.js 项目在本地机器上工作,在 Heroku 上部署时出现问题

javascript - Express 导出类中的箭头函数 - 意外的标记

sequelize.js - 如何在 sequelize 中使用 COUNT、GROUP BY、ORDER BY 编写查询

mysql - 使用 cls Sequelize 未获取当前上下文

mysql - 有没有一种快速方法可以将 1,000 个图像链接添加到 mysql 中的表中

mysql - 无法使用 MySQL Workbench 远程连接到 MySQL 服务器