wrong itemCount
qkrwnsgh1288 opened this issue · comments
qkrwnsgh1288 commented
I set the number of items per page to 50, but 18 is the output.
I guess, it seems to count the internal array length caused by Join.
I don't want to count internal array length(thingSensors
) together.
thing.service.ts
const things = await this.thingRepo
.createQueryBuilder('thing')
.leftJoin('thing.thingSensors', 'thingSensors')
.select(['thing.thingId', 'thingSensors']);
return paginate<Thing>(things, options);
thing.entity.ts
@OneToMany(() => ThingSensor, (thingSensor) => thingSensor.thing)
thingSensors: ThingSensor[];
Ashleigh Simonelli commented
Ah so, from your query you're querying thing
instead you should be querying thingSensors
and do a left join on the thing
table. This way round you'll end up counting the thing
table and not the thingSensors
table.