You can change the query other way around and get the house details
prisma.user.findUnique({
where: {
uuid: <given userId>
},
include: {
user: true
}
})
This should provide you with House details.
If you want to query on house model, you would need to enable extendedWhereUnique preview feature and make sure to pass atleast one unique attribute in the where clause.
Answer from Nurul Sundarani on Stack Overflowhow to include results from a relation table in a findUnique() query from another table
How to findUnique on a relation field in Prisma?
Prisma issue using include queries with extended methods
typescript - How to add type definitions for includes in a Prisma model? - Stack Overflow
if you are looking for a unique value that would bring you a single result you can use findFirst as well. which would give you Object instead of Array. findMany returns an Array even though you are looking for a unique value.
const users = await prisma.user.findFirst({
where: {OR: [{username},{email}]}
});
I am not entirely certain, but prisma returns a JS object...
So perhaps a query like this should work:
const query = await prisma.user.findUnique({
where: {
user: user.username
},
select: {
user: true,
email: true
}
});
I believe this should work, but it still only finds by one unique. I am not sure exactly why you would select user + email as both unique, as I would assume that one is tied to the other anyhow.
I would take a look over here for further answers if my solution was not able to work: https://www.prisma.io/docs/concepts/components/prisma-client/crud#findfirst
» npm install @giraphql/plugin-prisma