© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
elijah.01

Using extras in where

Hey, folks! Could you tell me, is it possible to get keys from "extras" in "where" for filtering?

let users = await db.query.UsersTable.findMany({
      extras: {
        targetName: sql<string>`lower(${UsersTable.firstName})`.as("target_name")
      },
      where: () =>
        and(
          inArray(
            UsersTable.id,
            employeesRoles.map((r) => r.userId)
          ),
          // here i need to use target_name for querying
        ),
      with: {
        roles: true
      }

  });
let users = await db.query.UsersTable.findMany({
      extras: {
        targetName: sql<string>`lower(${UsersTable.firstName})`.as("target_name")
      },
      where: () =>
        and(
          inArray(
            UsersTable.id,
            employeesRoles.map((r) => r.userId)
          ),
          // here i need to use target_name for querying
        ),
      with: {
        roles: true
      }

  });
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

Bug: Count in Extras (Relational)
Drizzle TeamDTDrizzle Team / help
9mo ago
aggregation core queries in extras?
Drizzle TeamDTDrizzle Team / help
16mo ago
non-SQL code in RQB extras
Drizzle TeamDTDrizzle Team / help
5mo ago
TypeError when using and() in where()
Drizzle TeamDTDrizzle Team / help
2y ago