Skip to content

Commit

Permalink
Added support for Model.getAssociatedModel({ through : { where : { ..…
Browse files Browse the repository at this point in the history
…. } }})
  • Loading branch information
mcarboni-redant authored and luin committed Feb 24, 2016
1 parent ae89e84 commit e71e520
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/associations/belongs-to-many.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ BelongsToMany.prototype.injectGetter = function(obj) {
throughWhere = {};
throughWhere[association.foreignKey] = instance.get(association.source.primaryKeyAttribute);

if (options.through && options.through.where)
throughWhere = { $and : [
throughWhere,
options.through.where
]};

if (through.scope) {
_.assign(throughWhere, through.scope);
}
Expand Down

0 comments on commit e71e520

Please sign in to comment.