© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
5 replies
jakeleventhal

Is there a smarter way to use optional query values

let newParentFolderId: string | undefined = getValue();

return db.query.imageFiles
  .findFirst({
    where: newParentFolderId ? eq(imageFiles.parentFolderId, newParentFolderId) : isNull(imageFiles.parentFolderId)
  })
.execute();
let newParentFolderId: string | undefined = getValue();

return db.query.imageFiles
  .findFirst({
    where: newParentFolderId ? eq(imageFiles.parentFolderId, newParentFolderId) : isNull(imageFiles.parentFolderId)
  })
.execute();

is there a cleaner way to not have to do things this way?
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

Is there a way to properly type a "generic query"
Drizzle TeamDTDrizzle Team / help
8mo ago
Smarter way to update while creating
Drizzle TeamDTDrizzle Team / help
3y ago
Smarter way to get schema type
Drizzle TeamDTDrizzle Team / help
3y ago
is there a way to use Redis in drizzle
Drizzle TeamDTDrizzle Team / help
2y ago