Skip to content

Instantly share code, notes, and snippets.

@Noerdsteil
Last active December 19, 2019 16:44
Show Gist options
  • Save Noerdsteil/7a5351917ef5968be1e869eced6fdefd to your computer and use it in GitHub Desktop.
Save Noerdsteil/7a5351917ef5968be1e869eced6fdefd to your computer and use it in GitHub Desktop.
Sequelize association in userEntity
User.associate = function ({ Company, UserRole, Role }) {
// association for or table not needed anymore
// models.User.hasMany(models.Order)
User.belongsTo(Company, { as: 'company' })
User.belongsToMany(Role, { as: 'roles')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment