Closed darvesh closed 6 years ago
'use strict'; module.exports = (sequelize, DataTypes) => { var Model = sequelize.define('Company', { name: DataTypes.STRING }); Model.associate = function(models){ this.Users = this.belongsToMany(models.User, {through: 'UserCompany'}); }; return Model; };
Can you please explain why this is used in this.Users = this.belongsToMany(models.User, {through: 'UserCompany'});
this
this.Users = this.belongsToMany(models.User, {through: 'UserCompany'});
How do I write belongsTo relation? I'm a beginner Thanks.
Nevermind. I understood.
Can you please explain why
this
is used inthis.Users = this.belongsToMany(models.User, {through: 'UserCompany'});
How do I write belongsTo relation? I'm a beginner Thanks.