Goal: Being able to fetch entity data with provided relations array.
More detailed: how to add .leftJoinAndSelect() methods n times depending on the relations array length and values. Is it possible to create some loop for adding leftJoinAndSelect() methods in the chain using relations array values?
Example for relations with 1 value only, but would like to make it flexible:
const relations = ['roles'];
const [results, total] = await queryBuilder
.leftJoinAndSelect(`&{alias}.${relations[0]}`, relations[0])
.take(limit)
.skip((page - 1) * limit)
.orderBy(`${alias}.${sortField}`, sortOrder)
.getManyAndCount();