Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamβ€’3y agoβ€’
7 replies
mcgrealife

Optional filter param, coalesce to true?

Is there a way to achieve this coalescing technique, but in valid drizzle sql?

const filterByBool: boolean | undefined | null = undefined

await db
  .select()
  .from(test)
  .where(test.bool == filterByBool ?? true)
const filterByBool: boolean | undefined | null = undefined

await db
  .select()
  .from(test)
  .where(test.bool == filterByBool ?? 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

coalesce
Drizzle TeamDTDrizzle Team / help
2y ago
utility function for COALESCE
Drizzle TeamDTDrizzle Team / help
14mo ago
Use COALESCE in index
Drizzle TeamDTDrizzle Team / help
2y ago
COALESCE to json array not working in sql function
Drizzle TeamDTDrizzle Team / help
13mo ago