SQLite
database.isTransaction
Reports whether a transaction is active on this connection. Use explicit rollback on failure rather than assuming a failed statement rolls back all previous statements. 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): ["true", "false"].
Formal Syntax & Structure
nodejs syntaxnodejs
database.isTransactionReturn Value
boolean
Transaction state.
Working Example
Example Snippetnodejs
import { DatabaseSync } from 'node:sqlite';const db = new DatabaseSync(':memory:');try { db.exec('BEGIN'); console.log(db.isTransaction); db.exec('ROLLBACK'); console.log(db.isTransaction);}finally { db.close();}