© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•5mo ago
Ven

non-SQL code in RQB extras

here is the custom fields doc for relational query builder: https://orm.drizzle.team/docs/rqb#include-custom-fields
i would like to have an "extra" field in my query that is generated via plain typescript, not sql. so, something like:
    const threads = await db.query.dmThread.findMany({
      where: or(eq(dmThread.userA, locals.user.id), eq(dmThread.userB, locals.user.id)),
      extras: {
          other: locals.user.id == dmThread.userA ? dmThread.userA : dmThread.userB
      }
  });
    const threads = await db.query.dmThread.findMany({
      where: or(eq(dmThread.userA, locals.user.id), eq(dmThread.userB, locals.user.id)),
      extras: {
          other: locals.user.id == dmThread.userA ? dmThread.userA : dmThread.userB
      }
  });

how can i do this while still preserving typing, concise code etc. that drizzle usually provides? do i really need to iterate over all this and do Object.assign (if so, how would i still ensure the data is typed?) or is there a better way?
Drizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
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

Non hardcoded strings in sql()
Drizzle TeamDTDrizzle Team / help
9mo ago
PostgreSQL RQB truncation
Drizzle TeamDTDrizzle Team / help
3y ago
Relational query `extras` are not properly adding sql
Drizzle TeamDTDrizzle Team / help
3y ago
Using extras in where
Drizzle TeamDTDrizzle Team / help
2y ago