From f046a9f605302faa76d87df2885bd7f40769a3f8 Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Fri, 18 Jan 2019 16:05:27 -0800 Subject: [PATCH] adding 'as' in associations --- app/config/associate.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/config/associate.js b/app/config/associate.js index 259dec6..a0e0271 100644 --- a/app/config/associate.js +++ b/app/config/associate.js @@ -4,18 +4,21 @@ module.exports = models => { Donors.hasMany(Grants, { foreignKey: 'donor_id' }); Grants.belongsToMany(Causes, { + as: 'GrantsCauses', through: 'grants_causes', foreignKey: 'grant_id', otherKey: 'cause_id' }); Grants.belongsToMany(Regions, { + as: 'GrantsRegions', through: 'grants_regions', foreignKey: 'grant_id', otherKey: 'region_id' }); Grants.belongsToMany(Organizations, { + as: 'GrantsOrganizations', through: 'grants_organizations', foreignKey: 'grant_id', otherKey: 'organization_id'