Hey guys, wha'ts up ? I'm having a hard time using...
# orm-help
e
Hey guys, wha'ts up ? I'm having a hard time using group by. I have a model of users which have properties like language and school uid. I want to a query which groups users who have the same school and languages. Here is my query:
this.prisma.users.groupBy({
by: ["uid","language", "school"]
})
Yet the only result I get is:
[
{ uid: 23, language: 'english', "school":"A "},
{ uid: 22, primary_language: 'french', "school":"B" },
{ uid: 24, primary_language: 'french' , "school":"B"}
]
Do you guys have any idea of how I can really group by school and name ? I have a result like:
[
[{ uid: 23, language: 'english', "school":"A "}],
[{ uid: 24, language: 'french', "school":"B "},  { uid: 22, language: 'french', "school":"B "}],
]
Thank you !! 🙂
b
I would
groupBy
school first, see if it works then add language and see if breaks. I do not understand why you are using
uid
there. Is it the
id
for the user?
n
Could you share your users model?
e
I need to add the uid of the users otherwise the payload returned will not have it and won't be able to identify users
Sure it is very basic, it for users it container their uid (which is their id in Integer) a language which is an enum and their school which is a many to many relation with the school.
v
@EdwinJr apologies for the delay in helping out with this problem, Nurul went on paternity leave, and unfortunately, I finished a monthly audit of unanswered questions only now! 😅 Have you perhaps already answered these questions or are you still looking for help?