npm better-sqlite3 3.0.0

latest releases: 9.6.0, 9.5.0, 9.4.5...
6 years ago

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 by Database.Integer which is a reference to the self-contained integer package. Database.Integer has a very different API from the old Database.Int64, and provides many powerful features and utilities. Read about it here.
  • All boolean options (like new Database(options.readonly) or statement.pluck(newState)) must be boolean if provided. Previously, they used the truthiness of whatever was provided, but now the provided value must either be true, 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 of Error, and has a code 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 at Database.SqliteError
  • 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 maximum array.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() and Transaction#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.

Don't miss a new better-sqlite3 release

NewReleases is sending notifications on new releases.