0
제목으로, 나는 Sequelize에서 다음/팔로어 관계를 수행하는 방법을 파악하려고합니다. 나는 레일스에서 노드로 한 일을 구현하려고 노력하고있다.노드 후속/후속 관계
그래서 heres는 루비 코드
InRelationship 모델 클래스 파일 루비
사용자 모델 클래스 파일에서belongs_to :follower, class_name: "User"
belongs_to :followed, class_name: "User"
루비
# Relationships
has_many :active_relationships, class_name: "Relationship", foreign_key: "follower_id", dependent: :destroy
has_many :following, through: :active_relationships, source: :followed
has_many :followers, through: :passive_relationships, source: :follower
has_many :passive_relationships, class_name: "Relationship", foreign_key: "followed_id", dependent: :destroy
지금 heres는 nodeJS Sequelize 이 코드를 번역 내 시도 사용자 파일 - NodeJS Sequelize
,Rleationship 파일 NodeJS Sequelize 내가 뭘 잘못
Relationships.belongsToMany(models.User,
{through: "active_relationships", as: "follower"})
Relationships.belongsToMany(models.User,
{through: "passive_relationships", as: "followed"})
? 이것은 내가 쿼리에 포함 시키려고 할 때 얻을 수있는 오류입니다.
처리되지 않은 거부 오류 : 관계 (active_relationships)가 사용자와 연결되어 있지 않습니다! 여기
내 쿼리를 포함한다
include: [
{model: models.Areas, as: "current_area" },
{model: models.VisitedAreas},
{model: models.OnTheWays, include: [
{model: models.Areas, as: "Area"}]},
{model: models.Settings},
{model: models.Pictures},
{model: models.Relationships, as: "passive_relationships"},
{model: models.Relationships, as: "active_relationships"}]
이 내 질문에 대답하지 않습니다. 사용자를 관계라는 모델에 연결시키고 다음 사용자와의 적극적인 관계와 그 사용자를 따르는 다른 사용자 인 수동적 관계가 있습니다. –
@TravisDelly 죄송합니다! – MWY
아직, 나는 아직도 당신이 사용해서는 안된다고 생각합니다! – MWY