i have many many enrollment relationship between 2 tables: students , courses this:
var enrollment = sequelize.define('enrollment', { enrollmenttype: { //some attributes }, { associate: function(models){ models.person.belongstomany(models.course, { as: 'courseenroll', through: { model: enrollment }, foreignkey: 'studentenrollid'}); models.course.belongstomany(models.person, { as: 'studentenroll', through: {model: enrollment},foreignkey: 'courseenrollid'}); } }
but need add third key period table have 3 unique key combination on enrollment table. tried doing:
enrollment.belongsto(models.period, { as: 'periodenroll', foreignkey: 'periodenrollid', primarykey: true,});
but didn't work, tried doing third belongstomany of other tables didn't work. how can archive this?
Comments
Post a Comment