MIKRO ORM: Load only the nested entities that fit the criteria

20 Views Asked by At

I have a series of nested entities that works like that:

queryBuilder
        .select(`*`)
        .joinAndSelect('project.segments', 's1', undefined, 'innerJoin')
        .joinAndSelect('s1.measurements', 'm2', undefined, 'innerJoin')
        .where('m2.updated_date >= ?', [ start ])
        .andWhere('m2.updated_date <= ?', [ end ])
        .andWhere('m2.measurement_type = ?', [ MeasurementTypeEnum.truck ])
        .orderBy([{'m2.updated_date': 'DESC'}])
        .limit(limit)
        .offset((page - 1) * limit)

Im trying to load the projects that have truck measurements. I'm having a issue here.

Even with this query, its loading all the segments and all the measurements for the project, not only the ones that fit the criteria.

0

There are 0 best solutions below