在Nodejs 10.15
和sequelize 5.7.6
中,有User
和Cellphone
个模型:
User
有一部手机:
{name: STRING,
cellphone_id: INTEGER}
和Cellphone
由用户添加:
{number: STRING,
created_by_id: INTEGER}
在associatioon.js
中,在hasOne
和hadMany
之间定义了两个关联User
和Cellphone
:
Cellphone.hasMany(User, {foreignKey: "cellphone_id"});
User.hasOne(Cellphone, {foreignKey: "created_by_id"});
在两个模型中同时使用hasOne
和hasMany
是否有冲突?或者,我只能与一个hasOne
或hasMany
建立一个关联,而不能同时建立两个关联。