Repository navigation
Releases
v0.3.12
This version fixes the error that readTransaction and syncedTransaction throw after a failed work. The API is the same.
- Each function sets a pragma again at the end:
query_onlyorsynchronous. Before this version, an error of that restore hid the error of the work. - After an error of the work, the work error stays the error of the function, and
onRollbackErrorgets the error of the restore. For example, SQLite refuses a change ofsynchronousin a transaction that a failed rollback did not end. - After a work with no error, an error of the restore is still the error of the function. The commit stays, and the connection keeps the setting of the work.
Runtime dependencies: none.
v0.3.11
This version changes only doc comments. The code and the API are the same as in 0.3.10.
- Each field of
Integrity(ok,problems) and ofSnapshot(path,bytes) has a doc comment. - A generator of procedures reads these comments. They become the descriptions of the output fields of the tools
sqlite.checkIntegrityandsqlite.snapshot.
Runtime dependencies: none.
v0.3.10
This version adds the synced transaction. The change is backward compatible.
syncedTransaction(db, work, options)does the work in oneBEGIN IMMEDIATEtransaction whose commit is on the disk when the function ends.- On a connection with
NORMAL, it setssynchronoustoFULLfor its commit, and sets the earlier value again at the end. A connection withFULLorEXTRAdoes not change. - A call in a transaction in progress throws. The rules of
transactionapply to the rollback, the synchronous work and the dry run. - The type
SyncedTransactionDatabaseis the part of a connection that the function uses. - The power-cut test has two new cases. With
NORMAL, the disk keeps each commit up to the last synced transaction.
Runtime dependencies: none.
v0.3.9
This version changes only the README. The code and the API are the same as in 0.3.8.
- The README has the section "What a power cut keeps". It gives the commits that each journal and
synchronoussetting kept in a power-cut test on LazyFS. FULLandEXTRAkept each commit. With WAL,NORMALkept the commits up to the last checkpoint.OFFkept no commit.- The row
synchronousof the options table links to the section.
Runtime dependencies: none.
v0.3.8
This version corrects the read of salvageEventLog on Node.js 22.13. The change is backward compatible.
- On Node.js 22.13, a garbage collection during the read of the broken log can finalize the statement of the read.
- Then the salvage stops with the error
ERR_INVALID_STATE, andopenCheckedEventLogcannot recover the file. - The salvage reads the broken log in pages of 500 rows with
all(). It does not useiterate(). - A test does a garbage collection after each 1000 events of a salvage of 50000 events. With the old read, it fails on Node.js 22.13.1.
Runtime dependencies: none.
v0.3.7
This version adds the checked open of an event log. The change is backward compatible.
openCheckedEventLog(path, parse, options)opens a log in its own file after an integrity check. The default check isquick_check.- The result is a tagged union with the kinds
created,opened,recoveredandorphan-journal. Its type isCheckedEventLog. - A broken file goes into quarantine, and a new file gets each readable event. The field
salvagehas the countskeptandlost. - A WAL, SHM or journal file with no database file goes into quarantine. The function does not put that WAL into a new file.
- Each step of the recovery can be done again. The record
<path>.recovery.jsonkeeps the quarantine folder and the counts across a crash. - A test stops the recovery after each step and opens the file again. The events and the quarantine are the same as after a recovery with no stop.
listRecoveries(path)gives each recovery from the records in the quarantine folders, in the sequence ofatand then ofid.- The
idof an entry is the name of its quarantine folder. A caller can report each recovery at each start with this id, and a grow-only log keeps one report. - A folder with no record, or with a record that does not parse, gives an entry of the kind
no-read. A recovery that is not complete is not in the list. - The types
CheckedEventLogOptions,RecoveryCause,RecoveryEntryandSalvageCountsare new.
Runtime dependencies: none.
v0.3.6
This version corrects the parameter type of confineToFile. The change is backward compatible.
confineToFiletakes aDatabaseSyncof each version of@types/node. Before, TypeScript refused theDatabaseSyncof@types/node22 with the error TS2559. That type has nosetAuthorizer, so it had no member in common withConfinableDatabase.- The parameter type is
DatabaseSync | ConfinableDatabase. Each call that compiled before still compiles. The check at run time does not change. - The typecheck of the package also examines the source and a type test with
@types/node22 (tsconfig.node22.json). The type test gives aDatabaseSyncof that version to each public function that takes a connection.
Runtime dependencies: none.
v0.3.5
This version adds a guard for the SQL text of a caller, and a function that gives each statement of a text. The change is backward compatible.
confineToFile(db)keeps the SQL of anode:sqliteconnection on its file. It refusesATTACHof a file,VACUUM INTO, the pragmastemp_store_directoryanddata_store_directory, and the functionload_extension.- Each other statement runs as before. A plain
VACUUMandclearDatabasealso work. - The guard does not limit the time or the size of the work of a caller. An
ATTACH ''can fill the temporary folder until the close. The host sets these limits. - The guard is the authorizer of SQLite, so it sees the statement after the parse. Comments, case and quotes do not change the result.
- The guard needs
setAuthorizerof Node.js 24.10 or later. On an earlier Node.js,confineToFilethrows the newConfineUnavailableError(code: "CONFINE_UNAVAILABLE"). The package still runs on Node.js 22.13. - The type
ConfinableDatabaseis the part of a connection that the guard uses. eachStatement(db, sql)gives each statement of a SQL text in order. The functionprepareofnode:sqlitecompiles only the first statement, and it ignores the rest with no error.eachStatementcompiles the next statement after the run of the statement before it. Thus a script can make a table and then write to it.- The types
SourcedStatementandStatementSourceare the parts of a statement and a connection thateachStatementuses.
Runtime dependencies: none.
v0.3.4
This version runs on Node.js 22.13 or later, and the adapter of sql.js operates after a save. The change is backward compatible.
- The
enginesfield asks for Node.js 22.13, not 22.16. CI runs the tests on Node.js 22.13 in a second job. transaction,readTransaction,checkpoint,clearDatabaseandeventLogread the transaction state through one function. A connection with noisTransactiongets the probe. Before, a connection fromnew DatabaseSync()on Node.js 22.13 to 22.15 had no state, so a failed work stayed in its transaction.eventLogandsalvageEventLogkeep a reference to the statement of a read. Before, Node.js 22.13 finalized that statement during some reads ("statement has been finalized").sqlJsConnectioncompiles a statement for each call and frees it after the call. Before, it kept one statement for each SQL text, and anexport()of sql.js frees each statement. So each call after the first save threw "Statement closed". The typeSqlJsStatementhas noreset, because the adapter does not use it. AStatementof sql.js still matches the type.- The tests do not use
isOpenor FTS5, because Node.js 22.13 has neither.
Runtime dependencies: none.
v0.3.3
This version adds the parts that the SQLite stores of other packages keep as local copies. The change is backward compatible.
openDatabasetakesreadOnly: the connection reads an existing file and does not change it. The optionwalalso takes"when-writable": a file that the process cannot write keeps its journal mode. The typeWalModeis new.transactiontakescommit: false: a dry run. The function rolls back after the work and gives the result of the work. This also applies to a savepoint.checkpointrunsPRAGMA wal_checkpointand gives its counts. The typesCheckpointMode,CheckpointedandCheckpointDatabaseare new.clearDatabasedrops each view and each table, and setsuser_versionto 0, for a cache that makes its tables again. The typeClearOptionsis new.sqlJsConnectiongives aSqlConnectionover a database of sql.js. The typesSqlJsDatabase,SqlJsStatement,SqlJsValueandSqlJsConnectionare structural, so the package has no new dependency.- Both entries export the new functions and types.
WalModeis only in the main entry. openDatabaseandsalvageEventLoguse the classDatabaseofnode:sqlitewhen it is there. Node.js 26.11 renamedDatabaseSynctoDatabase, and the old name gives a deprecation warning (DEP0210).- A Node.js before 22.16 has no
isTransaction. ThenopenDatabaseadds it to the connection as a probe: aBEGIN, which SQLite refuses in a transaction.sqlJsConnectionuses the same probe. Theenginesfield does not change. - One suite of tests runs the portable entry on
node:sqlite, SQLite in WebAssembly and sql.js.
Runtime dependencies: none.