Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groupBy give me incorrect result items #914

Open
Aung-Zaw-Phyo opened this issue Aug 13, 2024 · 0 comments
Open

groupBy give me incorrect result items #914

Aung-Zaw-Phyo opened this issue Aug 13, 2024 · 0 comments

Comments

@Aung-Zaw-Phyo
Copy link

Aung-Zaw-Phyo commented Aug 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant