matthewblewitt
matthewblewitt
DTDrizzle Team
Created by matthewblewitt on 6/29/2023 in #help
Infer TS types with `sql` operator and `db.execute`
const db = drizzle(connection);
export async function getTodos() {
const result = await db.execute<Todo>(sql`select * from ${todo}`);
return result.rows;
}
const db = drizzle(connection);
export async function getTodos() {
const result = await db.execute<Todo>(sql`select * from ${todo}`);
return result.rows;
}
result.rows is of type ExecutedQuery.rows: Row[] Is there a way to tell ts that it's of Type Todo[]?
5 replies