sql.raw with params array

Is there a way to create a SQL instance using something like sql.raw('select * from users where id = $1', ['user-id'])? I am not able to use string templates and I already have a Query object like {sql: "select * from users where id = $1", params: ["user-id"]} that I simply want to run.
1 Reply
cv01
cv01OP2mo ago
currently I'm resorting to using the underlaying postgres-js connection since 1. this doesn't seem possible with drizzle's magic sql thing 2. there's no way to get the underlaying postgres connection from a drizzle instance 🤦🏻‍♂️
const query = "select * from users where id = $1"
const params = [1]
postgres().unsafe(query, params as ParameterOrJSON<string>[])
const query = "select * from users where id = $1"
const params = [1]
postgres().unsafe(query, params as ParameterOrJSON<string>[])

Did you find this page helpful?