With Query mode, is possible filter by a related table?

Is possible using db.query to filter (where) using a related table?

Example:
const users = await db.query.posts.findMany({
    where: (users, { eq }) => eq(posts.user.id, 1), // related user with post
})


I know we can use with, but with will return the result and we can filter the with, I wanna filter the actual query using the related table.
We can do using the select
await db.select().from(posts).rightJoin(users, eq(users.id, posts.userId)).where(eq(posts.userId, users.id)
Was this page helpful?