Skip to main content
Module

x/sqlite3/mod.ts>Database#queryArray

Fast, native bindings to SQLite3 C API, using Deno FFI.
Go to Latest
method Database.prototype.queryArray
Re-export
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 });

Type Parameters

optional
T extends unknown[] = any[]

Parameters

strings: TemplateStringsArray

SQL query to execute.

...args: BindValue[]

Parameters to bind to the query.

Returns

T[]

Array of rows (where rows are containing array of columns).

Type Parameters

optional
T extends unknown[] = any[]

Parameters

sql: string
...args: BindValue[]

Type Parameters

optional
T extends unknown[] = any[]

Parameters

sql: string
args: Record<string, BindValue>