I am using Sequlize PostgreSQL. I have some table below
Campaigna( id, title )
BPCampaigna( id, user_id(forignkey), campaign_Id(forigen_key) )
Usera( id, name, conatct )
我正在尝试获得所有基调以及所有基点的详细信息,如
{
id: 1,
title: 'campaign title',
bp:{
id: 1,
name: 'Bp'
conatct: '454545
}
}
[我尝试查找包含BPCampaign的广告系列,然后正常工作,但是尝试查找包含Bpcampaign的广告时,用户就会出错。
Campaign.findAll({
where: {
deleted: 0
},
include: [
{
model: relatedModel,
include: [User]
}
]
})
错误:users is not associated to bp_campaigns!
您没有为BpCampaign定义关联
BpCampaign.belongsTo(user, { foreignKey: 'aquisition_member_id' });