import { Database } from "https://deno.land/x/sqlite3@0.4.4/mod.ts";
Runs an SQL query with given parameters, and returns rows as array of columns.
If you need the rows as objects, use queryObject
instead. However, it is
recommended to use queryArray
because of the extra overhead added by FFI
calls to get column names to create row objects.
Example:
const users = db.queryArray<[number, string]>("select id, username from users");
// Using bind parameters
const [user] = db.queryArray<[number, string]>("select id, username from users where email = ?", email);
// Using template strings
const [user] = db.queryArray<[number, string]>`select id, username from users where email = ${email}`;
// Using named bind parameters
const [user] = db.queryArray<[number, string]>("select id, username from users where email = :email", { email });
Parameters
...args: BindValue[]
Parameters
args: Record<string, BindValue>