``` console.log(session.id); const userTok...
# orm-help
l
Copy code
console.log(session.id);

    const userToken = await prisma.account.findFirst({
      where: { id: session?.id },
    });
    console.log(userToken);
Hey all. Just found an issue with my prisma query. When trying to
findFirst
by
id
with a value that is
undefined
it returns the first document in the database. Surely it should only return something if the value
id
was found? In the code above,
session.id
is undefined. the
console.log(userToken)
returns the first account in the database.
1
n
Hey Logan 👋 This is expected behaviour. Here’s a reference on how null and undefined are treated in PrismaClient. Essentially passing undefined in session.id would result into this:
Copy code
const userToken = await prisma.account.findFirst({
      where: { },
    });
which would just return the first record.
1
l
Thanks for the clarification :)