loobydooby
loobydooby
PPrisma
Created by loobydooby on 11/1/2024 in #help-and-questions
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
}
}
}
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
}
}
}
6 replies