记录一下 typeORM 非关联关系的查询
const tracks = this.componentRepo.createQueryBuilder('component')
.leftJoinAndMapOne('component.projectInfo', ProjectInfo, 'projectInfo', 'projectInfo.id = component.info')
.leftJoinAndMapOne('component.application', Application, 'application', 'application.id = projectInfo.application')
.leftJoinAndMapOne('component.customer', Customer, 'customer', 'customer.id = projectInfo.customer')
.innerJoinAndMapOne('component.project', Project, 'project', 'project.info = projectInfo.id')
.where("FIND_IN_SET(:employeeId, project.employeeIds)", { employeeId })
.andWhere("component.status IN (:status)", { status })
.getMany()
在上面查询中, 直接导入了相关实体 ProjectInfo, Application, 这些实体之间并没有创建关系系统, 用的是 副键关联.