2
我將選擇用戶詳細信息作爲表結構。sequelize js多級表casecade加入
表用戶列{USER_ID,REGION_ID,USER_NAME}
表區域列{REGION_ID,COUNTRY_ID}
表列國家{COUNTRY_ID,COUNTRY_NAME}
我加盟表模型爲
db.user.hasOne(db.region, {foreignKey:"region_id", targetKey:"region_id"});
db.region.hasOne(db.country,{ foreignKey :"country_id", targetKey:"country_id" });
db.user.hasOne(db.country,{through:db.region,otherKey :"country_id", foreignKey :"user_id" });
現在我是goi NG選擇用戶詳細信息包含區域名稱,這裏包含的國家名字是我的控制器
models.user.findAll(
{
include: [
{
model: models.region,
model: models.country
}
]
});
但這個節目的用戶不符合國家相關聯
請救救我