Skip to main content

SQLiteClient

@webda/sqlite


Class: SQLiteClient

Defined in: sqlite/src/connection.ts:98

Adapter of a DatabaseSync to the SQLClient interface, with a bounded prepared statement cache

Implements​

  • SQLClient

Constructors​

Constructor​

new SQLiteClient(db, cacheSize?): SQLiteClient

Defined in: sqlite/src/connection.ts:105

Parameters​

db​

DatabaseSync

the open database

cacheSize?​

number = 256

max prepared statements kept

Returns​

SQLiteClient

Properties​

cacheSize​

protected readonly cacheSize: number = 256

Defined in: sqlite/src/connection.ts:107

max prepared statements kept


db​

readonly db: DatabaseSync

Defined in: sqlite/src/connection.ts:106

the open database


statements​

protected statements: Map<string, StatementSync>

Defined in: sqlite/src/connection.ts:99

Methods​

query()​

query(sql, values?): Promise<{ rowCount: number; rows: any[]; }>

Defined in: sqlite/src/connection.ts:134

SELECT / WITH / PRAGMA statements run with all(), the others with run(); the method is async to honor SQLClient

The statement kind is read from its first keyword only: a value inlined in a WHERE clause can never change it. Use rows for a write statement with a RETURNING clause.

Parameters​

sql​

string

the statement

values?​

any[] = []

the parameters

Returns​

Promise<{ rowCount: number; rows: any[]; }>

the rows, or the number of changed rows

Implementation of​

SQLClient.query


rows()​

rows(sql, values?): Promise<any[]>

Defined in: sqlite/src/connection.ts:151

Run a statement returning rows, a write with a RETURNING clause included

Parameters​

sql​

string

the statement

values?​

any[] = []

the parameters

Returns​

Promise<any[]>

the rows


run()​

protected run<R>(sql, execute): R

Defined in: sqlite/src/connection.ts:161

Run a statement, translating the engine errors

Type Parameters​

R​

R

Parameters​

sql​

string

the statement

execute​

() => R

the execution

Returns​

R

the execution result


statement()​

protected statement(sql): StatementSync

Defined in: sqlite/src/connection.ts:114

Parameters​

sql​

string

the statement

Returns​

StatementSync

the prepared statement, cached