Execute the prepared statement and return the first result.
If no result is returned, this returns null.
method
Execute the prepared statement and return the first result.
If no result is returned, this returns null.
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 type | SQLite type |
|---|---|
string | TEXT |
number | INTEGER or DECIMAL |
boolean | INTEGER (1 or 0) |
Uint8Array | BLOB |
Buffer | BLOB |
bigint | INTEGER |
null | NULL |