Mget
Bun

method

sqlite.Statement.get

...params: ParamsType
): null | ReturnType;

Execute the prepared statement and return the first result.

If no result is returned, this returns null.

@param params

optional values to bind to the statement. If omitted, the statement is run with the last bound values or no parameters if there are none.

const stmt = db.prepare("SELECT * FROM foo WHERE bar = ?");

stmt.get("baz");
// => {bar: "baz"}

stmt.get();
// => null

stmt.get("foo");
// => {bar: "foo"}

The following types can be used when binding parameters:

JavaScript typeSQLite type
stringTEXT
numberINTEGER or DECIMAL
booleanINTEGER (1 or 0)
Uint8ArrayBLOB
BufferBLOB
bigintINTEGER
nullNULL