1
依賴鏈:關係 - >用戶=>關係Sequelize:循環依賴發現
的目標是關係到有user_one,user_two和LAST_USER行動。標準的user_one,user_two關係可以正常工作,但是當我嘗試在Relationships.hasOne()中添加last_user_action時,我得到一個依賴鏈錯誤。有沒有快速解決這個問題?
var Relationships = sequelize.define(
"Relationships",
{
type: DataTypes.ENUM('block', 'follow', 'pending')
},
{
classMethods: {
associate: function(models) {
Relationships.hasOne(models.Users, { as: 'lastUserAction', foreignKey: 'last_user_action' });
}
},
tableName: "relationships"
}
);
var Users = sequelize.define(
"Users",
{
firstName: DataTypes.STRING
},
{
classMethods: {
associate: function(models) {
Users.belongsToMany(models.Users, { as: 'userRelationship', through: models.Relationships, foreignKey: 'user_one_id', otherKey: 'user_two_id' });
}
},
tableName: "users"
}
);
有無接受之前等待23小時以上 –