Skip to main content
Module

x/sqlite3/mod.ts>Statement

Fastest & correct JavaScript bindings to SQLite3 C API, using Deno FFI.
Go to Latest
class Statement
Re-export
import { Statement } from "https://deno.land/x/sqlite3@0.5.1/mod.ts";

Represents a prepared statement.

See Database#prepare for more information.

Constructors

new
Statement(db: Database, sql: string)

Properties

readonly
bindParameterCount: number

Number of parameters (to be) bound

readonly
columnCount: number

Column count in current row.

readonly
expandedSql: string

SQL string including bindings

readonly
readonly: boolean

Whether this statement doesn't make any direct changes to the DB

readonly
sql: string

The SQL string that we passed when creating statement

readonly
unsafeHandle: Deno.PointerValue

Unsafe Raw (pointer) to the sqlite object

Methods

all<T extends Record<string, unknown> = Record<string, any>>(...args: RestBindParameters): T[]

Run the query and return the resulting rows where rows are objects mapping column name to their corresponding values.

bind(...params: RestBindParameters): this

Bind parameters to the statement. This method can only be called once to set the parameters to be same throughout the statement. You cannot change the parameters after this method is called.

This method is merely just for optimization to avoid binding parameters each time in prepared statement.

bindParameterIndex(name: string): number

Get bind parameter index by name

bindParameterName(i: number): string

Get bind parameter name by index

columnName(index: number): string

Return the name of the column at given index in current row.

finalize(): void

Free up the statement object.

get<T extends Array<unknown>>(): T | undefined

Fetch only first row, if any.

run(...args: RestBindParameters): number

Simply run the query without retrieving any output there may be.

toString(): string

Coerces the statement to a string, which in this case is expanded SQL.

values<T extends unknown[] = any[]>(...args: RestBindParameters): T[]

Run the query and return the resulting rows where rows are array of columns.

[Symbol.iterator](): IterableIterator<any>

Iterate over resultant rows from query.