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
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"),
},
});
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 - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
4 Replies
Sillvva
Sillvva5mo ago
I believe RQB v1 does not support nested where. However, RQB v2 beta does appear to support it. Beta docs: https://rqbv2.drizzle-orm-fe.pages.dev/ Beta discussion: #rqb-v2
Drizzle ORM - next gen TypeScript ORM.
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
SARAN
SARANOP5mo ago
If that's the case, then does it mean docs should be corrected. Because I am using latest version of drizzle and the piece of information is presented in stable version docs
Sillvva
Sillvva5mo ago
GitHub
Add nested filters for relational queries · drizzle-team drizzle-o...
I would like to create queries that filter by single values from a nested partial fields select. Imagine we have a users table with a one-to-one relation to a profile. The profiles table has a like...
officialankan
officialankan2mo ago
this also made me quite frustrated since i believed this was in the stable version since i was the reading the "official latest docs"

Did you find this page helpful?