© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
1 reply
Dush

How to deal with the type of response in sql'' template

How can we deal with the types of sql'' template since the result is accessable from the
rows
rows
property of result, Unlike the ORM itself.

const { rows } = await db.execute(
    sql`SELECT DISTINCT ${vehicleReferences.manufacturer} FROM ${vehicleReferences} WHERE ${vehicleReferences.vehType} = ${category}`
)

// Mapping the result to get only the brands as an Array
const vehTypes = rows.map((row) => row.manufacturer)

res.json({ brands: vehTypes })
const { rows } = await db.execute(
    sql`SELECT DISTINCT ${vehicleReferences.manufacturer} FROM ${vehicleReferences} WHERE ${vehicleReferences.vehType} = ${category}`
)

// Mapping the result to get only the brands as an Array
const vehTypes = rows.map((row) => row.manufacturer)

res.json({ brands: vehTypes })


For example rows are not type-safe here and I have to guess row manufacturer
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

How to specify type using sql template
Drizzle TeamDTDrizzle Team / help
3y ago
Issue with SUM in sql template
Drizzle TeamDTDrizzle Team / help
3y ago
How to use sql template strings
Drizzle TeamDTDrizzle Team / help
3y ago
Inconsistent Aliases in SQL Queries with findMany and `sql`` Template Literals
Drizzle TeamDTDrizzle Team / help
17mo ago