Say I have users and projects. Than I create a 1: m connection between them.
const User = sequlize.define("user", {...})
const Project = sequelize.define("project". {...})
User.hasMany(Project, { as: "projects" })
The farther secelize creates
addProject
for me automatically.
In other scenarios, I might need a custom function.
For example, I can check if this user of the project is allowed.
In other scenarios, I may also need to prevent the continuation of adding these association methods to my object.
My questions:
Is there a way to create a custom association method, if not, can I at least define a verification method?
Can I prevent the use of secelize to add a specific association method?
source
share