Replies: 1 comment 1 reply
-
Hi @gurbaaz27 👋 Thank you for raising this question. Prisma does not yet support filtering in the format you specified. The current approach you're using, fetching all users along with their comments and then filtering the results in your application code, is a valid method. However, I understand that this might not be the most efficient way, especially when dealing with large amounts of data. Can you please create a feature request and document your use case so that our engineers can take a look? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Question
I have a User Table and Comment Table with a one to many relationship, i.e., a user can have many comments, and a comment will have specific one user. I want to fetch all those users who have atleast 5 comments. For now, what I am doing is fetching all users along with their comments and then iterating through them and checking if
user.comments.length >= 5
. Is there any way to apply this filter within the prisma query itself? I could not find anything relevant on the internet regarding the same.How to reproduce (optional)
Expected behavior (optional)
No response
Information about Prisma Schema, Client Queries and Environment (optional)
// Add your schema.prisma
// Add any relevant Prisma Client queries here
OS:
Database:
Node.js version:
Run
prisma -v
to see your Prisma version and paste itBeta Was this translation helpful? Give feedback.
All reactions