Sequelize permissions table associate

c07d99bc-e19d-302d-8dea-dc98309bf919.jpg

refer to the figure above, existing

//
permission:{
    id:DataTypes.INTEGER,
    type:DataTypes.STRING
}
///
Operate:{
    id:DataTypes.INTEGER,
    name:DataTypes.STRING
    url:DataTypes.STRING
}

how to write associate? for permission Can you dynamically associate different tables according to type?
and permission:Operate is one-to-one, but sometimes polymorphic. I think it would be better to build a correlation table. How do I build the table at 1:1?

Mar.02,2021

sequelizejs establish a relationship through BelongsTo, BelongsToMany, HasMany, HasOne , and the associated query include is fine.
http://docs.sequelizejs.com/c.

Menu