FindFirst vs FindMany and Select

My goal is to just retrieve a candidate by it's id (the primary key of the Candidate table)

I'm using Bun sqlite as the database

I've written my query with select, findFirst and findMany but even though they generate the same sql query it does not give me results with findFirst.

Could someone help me understand what i did wrong please ? ^^'

const candidate: Candidate | undefined = await db.query.candidates.findFirst({
          where: eq(candidates.id, +params.id)
            });

const allCandidates = await db.select()
        .from(candidates)
        .where(eq(candidates.id, +params.id))
        .limit(1);

const allCandidates2 = await db.query.candidates.findMany({
        where: eq(candidates.id, +params.id),
        limit: 1
          });
image.png
Was this page helpful?