我有以下查询:
const records = await Product.findAll({
where: {
name: {
[Op.like]: '%iphone%'
}
Op.and( category {[Op.like]: '%phone%'})
}
})
如果我只有:
const records = await Product.findAll({
where: {
name: {
[Op.like]: '%iphone%'
}
}
})
我怎么能拥有它,这样查询的行为就像
SELECT * FROM Product WHERE name LIKE '%iphone%' AND 'category LIKE '%phone%'
我不断收到语法错误,有人可以帮我解决这个错误。
提前致谢
最佳答案
你缺少一些逗号。 WHERE clause documentation
const records = await Product.findAll({
where: {
name: { [Op.like]: '%iphone%' },
category: {[Op.like]: '%phone%'}
}
})
关于node.js - 如何在 Sequelize 中使用 and 运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59783265/