如何在 Sequelize 中设置两列相乘的 where 条件?
How to set a where condition on multiplication of two columns in Sequelize?
我将 Sequlize 5 与 PostgreSQL 结合使用。如何在 sequelize 中生成以下查询?
SELECT * FROM myTable
WHERE col1*col2 = 50
AND col3 = 'somthing'
感谢 Chris G,我终于使用 Op.and
、Sequelize.where
和 Sequelize.literal
解决了这个问题。这是我实现的解决方案:
MyTable.findAll({
where: {
[Op.and]: [
Sequelize.where(Sequelize.literal('col1*col2'), 50),
{ col3: 'somethimg' },
],
},
});
我将 Sequlize 5 与 PostgreSQL 结合使用。如何在 sequelize 中生成以下查询?
SELECT * FROM myTable
WHERE col1*col2 = 50
AND col3 = 'somthing'
感谢 Chris G,我终于使用 Op.and
、Sequelize.where
和 Sequelize.literal
解决了这个问题。这是我实现的解决方案:
MyTable.findAll({
where: {
[Op.and]: [
Sequelize.where(Sequelize.literal('col1*col2'), 50),
{ col3: 'somethimg' },
],
},
});