v3.0.0
This major version provides some powerful new features, introduces a better API for some functions, and comes with many small performance enhancements.
Breaking changes
- readonly mode has been reimplemented to use sqlite's engine-level readonly mode, instead of being implemented at the library level.
Database#pragma()
has been reworked to return proper result types (instead of just strings), and now works properly with readonly mode.Database#checkpoint()
has been completely reworked. It now accepts different arguments and has a different return value. By default, it now checkpoints all attached databases instead of just the main database. To learn how to use it, click here.- The
Database.Int64
class has been replaced byDatabase.Integer
which is a reference to the self-contained integer package.Database.Integer
has a very different API from the oldDatabase.Int64
, and provides many powerful features and utilities. Read about it here. - All boolean options (like
new Database(options.readonly)
orstatement.pluck(newState)
) must beboolean
if provided. Previously, they used the truthiness of whatever was provided, but now the provided value must either betrue
,false
, or omitted. An error will be thrown if a non-boolean value is provided.
Non-breaking new features
- The bundled sqlite3 engine has been upgraded to version 3.19.2.
- When an sqlite3-related error is thrown, it will be an
SqliteError
, which is a subclass ofError
, and has acode
property that corresponds to a result code.- This allows you to do checks like
if (err.code === 'SQLITE_CONSTRAINT_UNIQUE')
- The
SqliteError
class is available atDatabase.SqliteError
- This allows you to do checks like
Database#register()
now accepts generator functions, which registers a custom aggregate SQL function. To learn how to use them, read here.
Bug fixes and other minor improvements
- The
nan
package dependency has been removed, slightly improving performance. - When more than 4294967295 rows are returned by
Statement#all()
, an error is thrown instead of corrupting the results returned from the database (this is the maximumarray.length
in nodejs). - You can now use a combination of multiple prefixes (
$foo
,:foo
,@foo
) when creating a statement or transaction with named parameters. Previously this would result in errors being thrown. - The
Statement#bind()
andTransaction#bind()
methods can now be used even if the query was previously executed. - The performance of binding named parameters has been significantly improved.
- Many other minor performance enhancements.
Expected issues
The installation process has been completely rewritten, so I expect there to be installation issues when using Windows and/or Electron. If an issue like this comes up, please open an issue and I'll fix it as soon as possible.