Getting typescript error when using where clause inside with in query API.

Hi,
I need help in resolving the below mentioned typescript error
ts: Object literal may only specify known properties, and 'where' does not exist in type

on where clause inside assessment of this query
    const results = await db.query.assignments.findMany({
        where: (assignments, { eq: localEq }) =>
            localEq(assignments.assignedTo, candidateId),
        limit,
        offset,
        columns: {
            id: true,
            startsAt: true,
        },
        with: {
            assessment: {
                where: (assessments, { lt }) => lt(assessments.createdAt, new Date()), // <--- the error is here
                columns: {
                    id: true,
                    title: true,
                    timeLimit: true,
                },
            },
            assigner: {
                columns: {
                    name: true,
                },
            },
        },
        extras: {
            totalRecords: db
                .$count(assignments, eq(assignments.assignedTo, candidateId))
                .as("total_records"),
        },
    });

I saw the part of documentation where it says that it's possible to use where inside query API
https://orm.drizzle.team/docs/rqb#select-filters

I am using the following versions:
drizzle: ^0.43.1
drizzle-kit: ^0.31.1
typescript: ^5.8.3
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Was this page helpful?