시퀄라이즈 관계설정 에러

송민지·2022년 7월 19일
0

실전프로젝트

목록 보기
14/20

다른 모델을 include 하는 도중에

User is associated to User multiple times.
To identify the correct association, you must use the 'as' keyword to specify

요런 에러가 발생했다.

검색해보니 2개이상 연결된 관계는 include할때도 as를 작성해줘야 한다고 한다.

    include: [
      {
        model: User,
        as: 'guest',
        attributes: ['blogId'],
      },
    ],

처음 User 모델에서 생성할때 사용한 값을 적용하니 제대로 작동한다.


https://velog.io/@kaitlin_k/Sequelize-EagerLoadingError-assiciation-%EB%B3%84%EC%B9%AD-%EB%AF%B8%EC%84%A4%EC%A0%95-%EC%97%90%EB%9F%AC

profile
기록하는 일상

0개의 댓글