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}]}
});
Answer from Bora ALAP on Stack OverflowHow to exactly use FindUnique with array (aka FindMany)
MongoDB `findUnique()` or `findUniqueOrThrow()` leads to COLLSCAN if multiple queries happen at the same time
Allow findUnique to accept more than one search parameter
Prisma 2 Documentation on where clause with multiple conditions in update and delete statements
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