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

Eager loading with limit and order by edge field #4012

Open
ltns35 opened this issue Apr 11, 2024 · 0 comments
Open

Eager loading with limit and order by edge field #4012

ltns35 opened this issue Apr 11, 2024 · 0 comments

Comments

@ltns35
Copy link

ltns35 commented Apr 11, 2024

Hi,

I'm using the following code to eager loading a product with all its relationships, but I'm not receiving the correct values.

What I want to achieve is the following: retrieve a product with 5 stores that have the lowest final price.

entity, err := p.client.Product.Query().
	Where(product.IDEQ(id)).
	WithCategory().
	WithStorePricing(func(query *ent.StoreProductPricingQuery) {
		query.WithStore().
			WithPricing(func(q *ent.ProductPricingQuery) {
				q.Order(ent.Asc(productpricing.FieldPriceFinal))
			}).
			Limit(5)
	}).
	Only(ctx)
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