-
Adds support for Mapbox's/Ghost's SQLite3 v5.
-
Adds support for Joshua Wise's Better SQLite3 v8.
-
Uses SQLite v3.35's
INSERT … RETURNING
statement when possible to improve the performance ofHeaven.prototype.create
by permitting batched inserts (a singleINSERT
statement for all rows).
PreviouslyHeaven.prototype.create
inserted rows one by one and usedlast_insert_rowid()
to re-read them. This was necessary to get, e.g., the auto-incremented ids for the rows.Batched inserts may explicitly set some columns as
NULL
s that triggered the SQL schema'sDEFAULT
value before in situations where the array of attributes has inconsistent keys. That's because batch insert requires all rows to affect the same columns and there's no explicitDEFAULT
keyword in SQLite for a single value.Given this may affect someone depending on individual insertion and the defaulting behavior, bumping the major version.
-
Detects the maximum query variable count from SQLite's version.
In SQLite v3.32 the default was bumped from 999 to 32766.
- Adds support for Joshua Wise's Better SQLite3 v7.
This really just raised the peer-dependency version bounds.
-
Permits overwriting the
sqlite
andtable
properties by callingSqliteHeaven.prototype.with
:var heaven = new SqliteHeaven(Model, sqlite, "models") var newHeaven = heaven.with({sqlite: otherSqlite, table: "other_models"})
This could be handy if you pool Sqlite connections and want to overwrite the default connection of a Heaven instance with one that has a transaction open, for example.
-
Adds
SqliteHeaven.prototype.create_
for when you're not interested in the id of the created model(s). This both permits batch creating (a singleINSERT
statement) and improves performance by skipping parsing the returned attributes. -
Returns
undefined
fromSqliteHeaven.prototype.update
andSqliteHeaven.prototype.delete
instead of the Sqlite implementation's regular result.
Trying to always return the implementation's result (which was the number of rows updated with Better SQLite3) interferes with batching updates.
-
Adds support for Joshua Wise's Better SQLite3.
Better SQLite3 is also synchronous, so all of the CRUD methods ofBetterSqliteHeaven
are also synchronous. The Mapbox's SQLite3 version continues to be asynchronous and promised-based.You can get the data mapper for Better SQLite3 from
heaven-sqlite/better
:var SqliteHeaven = require("heaven-sqlite/better") var Sqlite3 = require("better-sqlite3") var sqlite = new Sqlite3.Database(":memory:") function Model(attrs) { Object.assign(this, attrs)} var modelsDb = new SqliteHeaven(Model, sqlite, "models")
-
HeavenSqlite.js's tests use the
async
feature of JavaScript and therefore require Node v7.6 or newer. HeavenSqlite.js itself should run well even in Node v4. -
Also upgrades Heaven.js to v0.12.
That version no longer instantiates models from attributes given toHeaven.prototype.create
. If you do need models for client-side default attributes, for example, instantiate them before callingHeaven.prototype.create
:var heaven = new SqliteHeaven(Model, sqlite, "models") heaven.create(new Model({name: "John"}))
- Upgrades Sqlate.js to v2.
See Sqlate.js's CHANGELOG for details.
- Stairway to SQLite.