const qb = dbConnection
.getRepository(AssignedWorkload)
.createQueryBuilder("aw")
.leftJoinAndSelect("aw.workload", "workload")
.leftJoinAndMapMany(
"aw.assignments",
"aw.assignedInteractions",
"workloadInteraction"
)
.leftJoinAndSelect("workloadInteraction.interaction", "interaction")
.leftJoinAndSelect("workloadInteraction.evaluation", "evaluation")
.leftJoinAndSelect("workload.interactionFilter", "interactionFilter")
.leftJoinAndMapOne(
"interaction.metadata",
`interaction.${IntegrationSystem.CHAT.toLowerCase()}Metadata`,
"metadata",
`metadata.id = interaction.${IntegrationSystem.CHAT.toLowerCase()}MetadataId`
);
I have this query that I created. Instead of hardcoding the left join column as such interaction.${IntegrationSystem.CHAT.toLowerCase()}Metadata
. My "workload" table has a relationship with interaction_filter table where can the IntegrationSystem value from the interaction_filter.integrationSystem column.
Would it be possible to run a subquery to join workload.interactionFilter then select the interactionFilter.integrationSystem column value then use that value while left joining interaction.metadata or I should execute a different query to get the system value?