SQLite

statement.get()

Reads the first result row or undefined. Add an appropriate order or unique predicate when a particular row is expected. The synchronous API can block the event loop; the 22.16.0 module is experimental. This fixture uses an isolated in-memory database. Tested on Node.js 22.16.0. Example output (one line per entry): ["book true"].

Formal Syntax & Structure

nodejs syntaxnodejs
statement.get([namedParameters][, ...anonymousParameters])

Parameters & Attributes

NameTypeDescription
namedParametersobjectNamed bind values.
anonymousParametersunknown[]Positional bind values.

Return Value

object | undefined

First row or absence.

Working Example

Example Snippetnodejs
import { DatabaseSync } from 'node:sqlite';const db = new DatabaseSync(':memory:');try {    const q = db.prepare('SELECT ? AS title WHERE ? > 0');    console.log(q.get('book', 1).title, q.get('book', 0) === undefined);}finally {    db.close();}
Node.js Reference