gpt4 book ai didi

javascript - Sequelize 查询返回 where like 和 where id 匹配

转载 作者:行者123 更新时间:2023-12-03 22:25:23 28 4
gpt4 key购买 nike

查询应该只返回与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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com