Is there a way to findOne with two terms? ```const...
# orm-help
a
Is there a way to findOne with two terms?
Copy code
const winnerSearch = await prisma.entries.findOne({
            where: {
                user: winner,
                lotto_id: parseInt(x)
            }
        })
Gives me an error
The error is
Copy code
Argument where of type EntriesWhereUniqueInput needs exactly one argument, but you provided user and lotto_id. Please choose one. Available args:
type EntriesWhereUniqueInput {
  id?: Int
  lotto_id?: Int
}
However I would only like to select the user with that specific lotto_id
That should do it
r
Hey @Alex Reyne 👋
findOne
only works on unique items. For non-unique items, you would need to use
findMany
.
p
I do it like this:
Copy code
const account = await prisma.account.findMany({where: {id: "sad", name: "sdaa"}).then(accounts=> accounts.length === 1 ? accounts[0] : undefined);
💯 1
a
Thanks all, sorry I ended up hopping off for the night