(targetModel, targetAlias)
| 736 | } |
| 737 | |
| 738 | static _getIncludedAssociation(targetModel, targetAlias) { |
| 739 | const associations = this.getAssociations(targetModel); |
| 740 | let association = null; |
| 741 | if (associations.length === 0) { |
| 742 | throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is not associated to ${this.name}!`); |
| 743 | } |
| 744 | if (associations.length === 1) { |
| 745 | association = this.getAssociationForAlias(targetModel, targetAlias); |
| 746 | if (association) { |
| 747 | return association; |
| 748 | } |
| 749 | if (targetAlias) { |
| 750 | const existingAliases = this.getAssociations(targetModel).map(association => association.as); |
| 751 | throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is associated to ${this.name} using an alias. ` + |
| 752 | `You've included an alias (${targetAlias}), but it does not match the alias(es) defined in your association (${existingAliases.join(', ')}).`); |
| 753 | } |
| 754 | throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is associated to ${this.name} using an alias. ` + |
| 755 | 'You must use the \'as\' keyword to specify the alias within your include statement.'); |
| 756 | } |
| 757 | association = this.getAssociationForAlias(targetModel, targetAlias); |
| 758 | if (!association) { |
| 759 | throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is associated to ${this.name} multiple times. ` + |
| 760 | 'To identify the correct association, you must use the \'as\' keyword to specify the alias of the association you want to include.'); |
| 761 | } |
| 762 | return association; |
| 763 | } |
| 764 | |
| 765 | |
| 766 | static _expandIncludeAll(options) { |
no outgoing calls
no test coverage detected