PrismaP
Prisma15mo ago
5 replies
loobydooby

Filter relationship by value in parent

I have a query where I'm trying to filter related objects by a value that will be found in the root of the query. example

const response = await prisma.myObject.findMany({
  where: {
    myKey: true
  },
  select: {
    someId: true, // I want to filter 'someRelatedModel' where someRelatedModel.someId == this
    someRelatedModel: {
      where: {
        someId: // Only give me 'someRelatedModels' wher this is the same as the someId above
      }
    }
  }
Was this page helpful?