© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
34 replies
desert

Nested where clauses in relational queries

I have this query:

const asset = await db.query.assets.findFirst({
with: {
assetImages : true,
assetModeration: {
where: eq(assetsModerations.state, "ACCEPTED"), //this line gives error
columns: {
state: true,
},
}
},
where: (eq(assets.id, id))
})

that gives this error: Object literal may only specify known properties, and 'where' does not exist in type ...
the assetsModerations table looks like this:

export const assetsModerations = pgTable(
"assets_moderations",
{
id: serial('id').primaryKey(),
created_at: timestamp('created_at').notNull().defaultNow(),
description: text('description'),
moderatorId: text("moderator_id").references(() => users.id),
updatedAt: timestamp('updated_at'),
state: moderationState('moderation_state').notNull().default('PENDING')
}
)

this error is not given if i try to do the same with assetImages, the other table, what is the problem here?
Thank you in advance.
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Where clauses across multiple tables in relational queries
Drizzle TeamDTDrizzle Team / help
3y ago
Extracting where clauses for automation for relational queries
Drizzle TeamDTDrizzle Team / help
3y ago
types from nested relational queries
Drizzle TeamDTDrizzle Team / help
3y ago
Error in relational queries
Drizzle TeamDTDrizzle Team / help
16mo ago