查询应该只返回与employeeId 和where 文件名匹配的记录,如context.data.filename 但它返回的代码存在问题,即使employeeId 不匹配。对这个家伙有什么想法吗?谢谢你。
#代码
const file = await context.service.Model.findAll({
query: {
employeeId: record.id,
$or: [
{
filename: {
$like: context.data.filename,
},
},
],
},
paranoid: false,
});
最佳答案
您不需要添加 OR,OR 与单个参数返回 true。试试这个:
const file = await context.service.Model.findAll({
query: {
$and: [
{
employeeId: record.id,
filename: {
$like: context.data.filename,
},
},
],
},
paranoid: false,
});
关于javascript - Sequelize 查询返回 where like 和 where id 匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63212728/