我要在不同的表中找到一個字段,即我要檢查搜索是否在Customer表的不同字段、Shops表的不同字段和ContactPerson表的不同字段中Customer 和 Persons 以及 Customer Shops 表是 1-N 并且相關(guān)聯(lián)我的“搜索”變量是我想要找到的。這是我的代碼CustomerPersonsRelation()CustomerShop() var result = await CustomerModel.findAll({ ...params, include: [ {model : ShopModel}, {model: ContactPersonModel} ] })都是進口的,不用擔心。我的參數(shù)是這些:{ 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”。(以及所有相關(guān)字段的此錯誤。)我能為那工作做些什么?
使用 OR 對多表關(guān)聯(lián)查詢進行 Sequelize
人到中年有點甜
2021-09-17 17:24:44