reinaldyrfl
reinaldyrfl
Explore posts from servers
DTDrizzle Team
Created by reinaldyrfl on 4/9/2024 in #help
How do I execute raw query (with params already separated) with Drizzle?
What I've tried (and of course, this does not work):
// Remember that `query` is a `string` type
// and `params` is `unknown[]` type
const queryChunks: SQLChunk[] = [];
queryChunks.push(sql.raw(query));
for (const param of params) {
queryChunks.push(sql.param(param));
}

const output = await this.database.execute<{ id: bigint; }>(new SQL(queryChunks)));
// Remember that `query` is a `string` type
// and `params` is `unknown[]` type
const queryChunks: SQLChunk[] = [];
queryChunks.push(sql.raw(query));
for (const param of params) {
queryChunks.push(sql.param(param));
}

const output = await this.database.execute<{ id: bigint; }>(new SQL(queryChunks)));
4 replies