This major version provides powerful new features, bug fixes, improved performance, and much much more.
Breaking changes
- Dropped support for Node.js versions < 8.
- Renamed
info.lastInsertROWID
toinfo.lastInsertRowid
(docs). - Renamed
stmt.returnsData
tostmt.reader
(docs). - The
db.pragma()
method now accepts{ simple: true }
instead of atrue
boolean (docs). - Redesigned the
db.transaction()
method:- Transaction objects have been removed.
- The
db.transaction()
method now takes a function and returns a function (a wrapper). - The returned function will automatically run inside a transaction.
- Nested transactions (savepoints) are supported.
- Read the full documentation here.
- Removed the
db.register()
method, added thedb.function()
anddb.aggregate()
methods:- The
db.function()
method is used to register regular user-defined functions. - The
db.aggregate()
method is used to register user-defined aggregate functions. - The APIs for both methods have been changed from the old
db.register()
method. Read the new documentation here and here, respectively. - The
db.aggregate()
method can also register window functions.
- The
- Enabled the
SQLITE_ENABLE_FTS3_PARENTHESIS
compilation option (more info). - When opening a database, the
memory
andreadonly
options are now mutually exclusive (docs). - Moved all documentation from the wiki to the repository itself (here).
- Documentation for the (deprecated) version v4.x.x can be found here.
Non-breaking new features
- SQLite3 was upgraded to version 3.25.2.
- Enabled the following compilation options:
- Users can now compile
better-sqlite3
against their own customized version of SQLite3: - If the process exits gracefully (i.e., the event loop has no more work to do), all open databases will automatically be closed. This does not happen for forced exits (i.e.,
process.exit()
,SIGINT
, etc.). - Added the
timeout
option when opening a database (docs). - Added support for anonymous in-memory databases, using the
":memory:"
filename (more info). - Added the
stmt.expand()
method, which namespaces result columns by table name (docs).
Bug fixes and other minor improvements
- Fixed a bug that caused
v8::ToLocalChecked Empty
. - Fixed a bug that caused
db.inTransaction
to betrue
when the database was closed. - Fixed a bug that prevented users from including trailing whitespace in prepared statements.
- Fixed many v8 deprecation warnings.
- Fixed many installation-related bugs.
- Improved performance of user-defined aggregate functions by ~15%.
- Added many other (minor) performance optimizations.