Closed daguitosama closed 5 months ago
Currently this is not supported.
However, you could use a tool like Kysely, Zapatos or Drizzle on top of the driver to achieve this.
I just wrote a quick hack. It probably breaks down during edge cases (arrayMode etc), but worked for the couple db calls I do from the edge.
import { neon } from "@neondatabase/serverless";
const sql = neon(process.env.NEON_DB_URL!);
export async function sqlNeon<T>(
query: TemplateStringsArray,
...params: any[]
): Promise<T> {
const result = await sql(query, ...params);
return result as T;
}
you could also just do something like:
const rows = (await sql`select * from users;`) as User[];
Im reading the examples and documentation on how to use the
client
you get out ofneon(DB_URL)
; but have not found any clear way to type the result of runing a query, like for instance, the waypostgres.js
folks do it:Is posible doing that typing ?
If not, i think would be a wonderful adition 😂