velt/db
API referenceWhat database drivers share: typed rows from any source of tabular data, and a statement's parameters handed to a native driver. The SQLite and PostgreSQL packages read their rows this way, so a typed query there (stmt.all<User>()) fills its Users by the rules on this page. For a walkthrough, read the guide.
Exports
T (see decodeRows).decodeRowsEvery row of a native driver's row cursor (its handle) as a T: each column fills the field of its name, as readRows fills them from a RowSource (the same conversions and messages).bindParamsHands params to a native driver's parameter sink (its handle) value by value: an array, a tuple or a lone value by position, an object's fields by name, each value bound as its JSON text would read back (an integral number an integer, NaN null, a u8[] field a blob).readRowThe next row of src as a T, or null when there is none.readRowsEvery remaining row of src as a T.RowErrorA row that does not fit the requested type (expected i64 at $[0].id).RowSourceRows as a driver produces them: their columns, and the current row's values by column.CellKindWhat a column of the current row holds.Re-exported from velt/db/native
function decodeRow<T>(cursor: u64): TThe one row of a native driver's row cursor opened for a single row, as a T (see
decodeRows). Throws RowError for a row that does not fit T, and for a handle that names
no open row cursor.
Re-exported from velt/db/native
function decodeRows<T>(cursor: u64): T[]Every row of a native driver's row cursor (its handle) as a T: each column fills the field
of its name, as readRows fills them from a RowSource (the same conversions and messages).
The cursor stays the driver's: give the handle back to the driver afterwards, which then
reports a failure met while stepping. Throws RowError for a row that does not fit T, and
for a handle that names no open row cursor.
Re-exported from velt/db/native
function bindParams<P>(sink: u64, params: P): boolHands params to a native driver's parameter sink (its handle) value by value: an array, a tuple or a lone
value by position, an object's fields by name, each value bound as its JSON text would read
back (an integral number an integer, NaN null, a u8[] field a blob). True once they went to
the sink; false, having done nothing, for a type it cannot take that way (a nested object, a
union): the driver then takes JSON.stringify(params) instead, which binds the same values.
False too for a handle that names no open parameter sink (nothing reaches memory; the driver
finds the handle dead when it is handed on).
Re-exported from velt/db/read
function readRow<T, S extends RowSource>(src: S): T | nullThe next row of src as a T, or null when there is none. Throws RowError as readRows
does.
Re-exported from velt/db/read
function readRows<T, S extends RowSource>(src: S): T[]Every remaining row of src as a T. Throws RowError for a row that does not fit, and with
the message of what the source's methods throw.
Re-exported from velt/db/errors
class RowError extends ErrorA row that does not fit the requested type (expected i64 at $[0].id).
constructor(message: string)No doc comment yetRe-exported from velt/db/row_source
Rows as a driver produces them: their columns, and the current row's values by column. The reader asks each value's kind before taking it with the getter of that kind.
columnCount(): i64The number of columns.
columnName(i: i64): stringThe name of column i (from 0): the field it fills.
next(): boolMoves to the next row (the first on the first call): false when there is none.
kind(i: i64): CellKindWhat column i of the current row holds.
bool(i: i64): boolNo doc comment yetint(i: i64): i64No doc comment yetfloat(i: i64): f64No doc comment yettext(i: i64): stringNo doc comment yetblob(i: i64): u8[]No doc comment yetjson(i: i64): stringNo doc comment yetRe-exported from velt/db/row_source
What a column of the current row holds.
Returned byRowSource.kind
NullNo doc comment yetBoolNo doc comment yetIntNo doc comment yetFloatNo doc comment yetTextText (UTF-8).
BlobBytes, a u8[].
JsonA nested value (an array or object) as its JSON text.