From deecba362f2f27db9196b49432f012101fd9bafc Mon Sep 17 00:00:00 2001 From: TimH Date: Thu, 4 May 2017 21:28:44 +0200 Subject: [PATCH] Added alias to artist/instrument relations such that populating the db works correctly --- api/models/artists.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/models/artists.js b/api/models/artists.js index a0050dd..7c94541 100644 --- a/api/models/artists.js +++ b/api/models/artists.js @@ -64,10 +64,10 @@ module.exports = function(sequelize, DataTypes) { }, { freezeTableName: true, // Model tableName will be the same as the model name classMethods: { - associate: function(models) { - this.belongsToMany(models.works, {through:'ArtistComposedWork'}); - this.belongsToMany(models.instruments, {through:'ArtistPlayedInstrument'}); - this.belongsToMany(models.instruments, {through:'ArtistComposedInstrument'}); + associate: function (models) { + this.belongsToMany(models.works, {through: 'ArtistComposedWork'}); + this.belongsToMany(models.instruments, {through: 'ArtistPlayedInstrument', as: 'Player'}); + this.belongsToMany(models.instruments, {through: 'ArtistComposedInstrument', as: 'Composer'}); this.belongsTo(models.entities); }