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

Support nested orderBy #2297

Open
steebchen opened this issue May 10, 2024 · 0 comments
Open

Support nested orderBy #2297

steebchen opened this issue May 10, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@steebchen
Copy link

Describe what you want

Assuming I have a table tags and products with a many-to-many relation on table productsToTags. I would like to query by a few specific tag IDs and order it by the most popular products. However, this is not possible right now because the orderBy does not include the product info.

const products = await db().query.tags.findMany({
  with: {
    productsToTags: {
      with: {
        product: true,
      },
                                      // .product is undefined
      orderBy: (pt, { desc }) => [desc(pt.product.popularity)],
    },
  },
  limit: 3,
})
@steebchen steebchen added the enhancement New feature or request label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant