nestjsx / nestjs-typeorm-paginate

:page_with_curl: Pagination response object function + types for typeorm + nestjs
MIT License
840 stars 122 forks source link

groupBy give me incorrect result items #914

Open Aung-Zaw-Phyo opened 1 month ago

Aung-Zaw-Phyo commented 1 month ago

If i don't add groupBy, result items are not correct. That's why I add groupBy. But when i add groupBy, relationship items are not correct. Example, there are many items in categories relationship but it return first item of relationship items.

async paginate(options: IPaginationOptions): Promise<Pagination<Product>> {
    const queryBuilder = this.repo.createQueryBuilder('c');
    queryBuilder
        .leftJoinAndSelect('c.categories', 'categories')
        .leftJoinAndSelect('c.variants', 'variants')
        .leftJoinAndSelect('c.images', 'images')
        .groupBy('c.id')
        .orderBy('c.createdAt', 'DESC');
    return paginate<Product>(queryBuilder, options);
}

Please give me some good ideas