I am trying to only return items from our DB, if the children within an include
exists.
I am using Prisma to query our postgres DB. Previously, using sequelize, you could add a required:true
to the include, meaning only items that had this include would be returned. However, I can not seem to do this with Prisma, so its returning many more items that I don't need.
Here is the structure that i have:
where: {
...parameters_.where,
},
include: {
Products: {
where: {
active: true,
ParentId: parameters_.ParentId,
},
}
}
So I only want to return the top level, if Products actually exists. (This will return an array, and currently it returns if the Products array is empty as well as when its not).
As mentioned, with sequelize it was possible to do the following:
include: [
{
model: ModelName,
as: "modelName",
required: true
},
]