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.
Was this page helpful?