#List of users who share at least one group

5 messages · Page 1 of 1 (latest)

lethal moat
#

I have the following models:

model User {
  id String @id
  username String
  displayName String
  wishlist String
  groups Group[]
}

model Group {
  id String @id
  name String
  members User[]
}

When a user looks at the wishlists page, it should contain a list of all users who are in any of the groups that the user is in. What's the best way to accomplish this?

#

Is there a way to do it with one query or do I need to fetch the groups the user is in then fetch all of the users who have any of the groups?

granite socket
# lethal moat I have the following models: ``` model User { id String @id username String ...

Hi vmathi

To fetch a list of users who are in any of the groups that a specific user is in, you can use Prisma's findMany function with the where and include options.

Then, you can use the findMany function with the where option to filter users based on the groups. In the where clause, you can use the some keyword to filter users who are in any of the groups that the specific user is in.

lethal moat
granite socket