Closed grenierdev closed 2 years ago
That's correct. SQLite queries always return zero or more rows with zero or more items each. So query
should always return SomeTuple[]
.
E.g. this would return:
import { DB } from "https://deno.land/x/sqlite/mod.ts";
const db = new DB();
const result = db.query("SELECT 1, 2, 3");
console.log(result); // [ [ 1, 2, 3 ] ]
https://github.com/dyedgreen/deno-sqlite/blob/3b491b1ceda495f1bbc9069b2c44a5cbf2d80cec/src/db.ts#L107
Being
<R extends Row = Row>
andtype Row = Array<unknown>
basically means that I'm forced to usedb.query<Something[]>(...)
instead ofdb.query<Something>(...)
. The former has a return type ofSomething[][]
instead ofSomething[]
.