import { Database } from "https://deno.land/x/sqlite3@0.4.4/mod.ts";
Executes an SQL query and returns the rows as objects.
Note: if you do not need the column names, consider calling queryArray
instead.
As this method does an extra FFI call to get the column names, it is more expensive than queryArray
.
Example:
const users = db.queryObject<{
id: number,
username: string,
}>("select id, username from users");
// Using bind parameters
const [user] = db.queryObject<{
id: number,
username: string,
}>("select id, username from users where email = ?", email);
// Using template strings
const [user] = db.queryObject<{
id: number,
username: string,
}>`select id, username from users where email = ${email}`;
// Using named bind parameters
const [user] = db.queryObject<{
id: number,
username: string,
}>("select id, username from users where email = :email", { email });
Parameters
...args: BindValue[]
Parameters
args: Record<string, BindValue>