limbo/bindings/wasm/docs/api.md
Pekka Enberg 7943fa1e35 bindings/wasm: Add API reference document
The aim is towards libSQL/better-sqlite3 compatibility. Lift the API
reference document from libsql-js.git and update it accordingly to what
`limbo-wasm` supports.
2024-12-16 18:45:18 +02:00

3.7 KiB

class Database

The Database class represents a connection that can prepare and execute SQL statements.

Methods

new Database(path) ⇒ Database

Creates a new database connection.

Param Type Description
path string Path to the database file

prepare(sql) ⇒ Statement

Prepares a SQL statement for execution.

Param Type Description
sql string The SQL statement string to prepare.

The function returns a Statement object.

transaction(function) ⇒ function

This function is currently not supported.

pragma(string, [options]) ⇒ results

This function is currently not supported.

backup(destination, [options]) ⇒ promise

This function is currently not supported.

serialize([options]) ⇒ Buffer

This function is currently not supported.

function(name, [options], function) ⇒ this

This function is currently not supported.

aggregate(name, options) ⇒ this

This function is currently not supported.

table(name, definition) ⇒ this

This function is currently not supported.

loadExtension(path, [entryPoint]) ⇒ this

This function is currently not supported.

exec(sql) ⇒ this

This function is currently not supported.

close() ⇒ this

This function is currently not supported.

class Statement

Methods

run([...bindParameters]) ⇒ object

This function is currently not supported.

get([...bindParameters]) ⇒ row

Executes the SQL statement and returns the first row.

Param Type Description
bindParameters array of objects The bind parameters for executing the statement.

all([...bindParameters]) ⇒ array of rows

Executes the SQL statement and returns an array of the resulting rows.

Param Type Description
bindParameters array of objects The bind parameters for executing the statement.

iterate([...bindParameters]) ⇒ iterator

Executes the SQL statement and returns an iterator to the resulting rows.

Param Type Description
bindParameters array of objects The bind parameters for executing the statement.

pluck([toggleState]) ⇒ this

This function is currently not supported.

expand([toggleState]) ⇒ this

This function is currently not supported.

raw([rawMode]) ⇒ this

Toggle raw mode.

Param Type Description
rawMode boolean Enable or disable raw mode. If you don't pass the parameter, raw mode is enabled.

This function enables or disables raw mode. Prepared statements return objects by default, but if raw mode is enabled, the functions return arrays instead.

columns() ⇒ array of objects

This function is currently not supported.

bind([...bindParameters]) ⇒ this

This function is currently not supported.