Creating instance with an association in Sequelize

后端 未结 8 1022
清酒与你
清酒与你 2021-02-02 09:09

Using Sequelize, I\'ve created two models: User and Login.

Users can have more than one Login, but a login must have exactly one user, which me

8条回答
  •  深忆病人
    2021-02-02 09:28

    I have the same issue recently! I have a typo mistake with the foreignKey config. Use field instead of name caused the issue.

    The change below will fix it.

    {
        foreignKey: {
           name: 'userId',
           allowNull: false,
        }
    }
    

提交回复
热议问题