Sequelize Associations

YoungJoon Suh·2022년 4월 12일
0
  1. one-to-one:
    A.hasOne(B): One-To-One relationship exists between A and B. Target model B 에 foreign key가 정의되어 있다.
    A.belongsTo(B): One-To-One relationship exists between A and B. Source model A 에 foreign key가 정의되어 있다.

  2. one-to-many:
    A.hasMany(B): One-To-Many relationship exists between A and B. Target model B 에 foreign key가 정의되어 있다.

  3. many-to-many:
    A.belongsToMany(B, { through: 'C' }): Many-To-Many relationship exists between A and B, using table C as junction table, which will have two foreign keys (aid and bid for example). Sequelize will automatically create this model C (unless it already exists) and define the appropriate foreign keys on it.

profile
저는 서영준 입니다.

0개의 댓글