我要在不同的表中找到一个字段,即我要检查搜索是否在Customer表的不同字段、Shops表的不同字段和ContactPerson表的不同字段中
Customer 和 Persons 以及 Customer Shops 表是 1-N 并且相关联
我的“搜索”变量是我想要找到的。
这是我的代码
CustomerPersonsRelation()
CustomerShop()
var result = await CustomerModel.findAll({
...params,
include: [
{model : ShopModel},
{model: ContactPersonModel}
]
})
都是进口的,不用担心。我的参数是这些:
{
where: {
$or: [
{
'$Customer.customer_name$': { $like: '%' + search + '%' },
},
{
'$Customer.customer_fiscal_name$': { $like: '%' + search + '%' },
},
{
'$Customer.customer_responsable_name$': { $like: '%' + search + '%' },
},
{
'$Customer.customer_responsable_phone$': { $like: '%' + search + '%' },
},
{
'$Customer.customer_web$': { $like: '%' + search + '%' },
},
{
'$Shops.shop_name$': { $like: '%' + search + '%' },
},
{
'$Shops.shop_phone$': { $like: '%' + search + '%' },
},
{
'$Shops.shop_mobile$': { $like: '%' + search + '%' },
},
{
'$ContactPersons.contactp_name$': { $like: '%' + search + '%' },
},
{
'$ContactPersons.contactp_phone$': { $like: '%' + search + '%' },
},
{
'$ContactPersons.contactp_mobile$': { $like: '%' + search + '%' },
}
]
},
limit: 3
})
}
但这会返回此错误:错误:SequelizeDatabaseError:无法绑定多部分标识符“ContactPersons.contactp_mobile”。(以及所有相关字段的此错误。)
我能为那工作做些什么?
呼唤远方
相关分类