(targetModel, targetAlias)
| 713 | } |
| 714 | |
| 715 | static _getIncludedAssociation(targetModel, targetAlias) { |
| 716 | const associations = this.getAssociations(targetModel); |
| 717 | let association = null; |
| 718 | if (associations.length === 0) { |
| 719 | throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is not associated to ${this.name}!`); |
| 720 | } |
| 721 | if (associations.length === 1) { |
| 722 | association = this.getAssociationForAlias(targetModel, targetAlias); |
| 723 | if (association) { |
| 724 | return association; |
| 725 | } |
| 726 | if (targetAlias) { |
| 727 | const existingAliases = this.getAssociations(targetModel).map(association => association.as); |
| 728 | throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is associated to ${this.name} using an alias. ` + |
| 729 | `You've included an alias (${targetAlias}), but it does not match the alias(es) defined in your association (${existingAliases.join(', ')}).`); |
| 730 | } |
| 731 | throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is associated to ${this.name} using an alias. ` + |
| 732 | 'You must use the \'as\' keyword to specify the alias within your include statement.'); |
| 733 | } |
| 734 | association = this.getAssociationForAlias(targetModel, targetAlias); |
| 735 | if (!association) { |
| 736 | throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is associated to ${this.name} multiple times. ` + |
| 737 | 'To identify the correct association, you must use the \'as\' keyword to specify the alias of the association you want to include.'); |
| 738 | } |
| 739 | return association; |
| 740 | } |
| 741 | |
| 742 | |
| 743 | static _expandIncludeAll(options) { |
no outgoing calls
no test coverage detected