github dexie/Dexie.js v3.0.0-alpha.3
Dexie v3.0.0-alpha.3

latest releases: v4.0.0-alpha.4, v3.0.4, v4.0.0-alpha.3...
pre-release6 years ago

Overview of Changes

  • Improved Database Upgrading (see "Details" below)
  • Improved Node support (when used together with IndexedDBShim on node)
  • Failing gracefully when cookies are disabled in Firefox (#619). This fix was also committed to master-2 and release in latest stable (v2.0.4).
  • #696 Possible to query multiple multiEntry properties using db.table.where({tags: 'browser', categories: 'database'}).
  • #692 Console warnings with indexing advices shall only happen in debug mode.
  • Improved tests

Details

Improved Database Upgrading (PR #714)

It is now possible to read data from a table in upgrader and delete the same table in a later db-version. It is now also possible to change a primary key of a table (on all platforms except IE and Edge). You could also change the table's name, or use data from one table into other tables, and then delete the origin table.

This has been an issue for years, mentioned in #88#105, #287 and #713.

To take advantage of the new upgrade support, upgrade() functions can only access such tables through the transaction instance given to the upgrade function (single argument) and not through the Dexie instance. The specific scenario that is now possible in 3.0.0-alpha.3 and later, is the following:

const db = new Dexie('MyDatabase');
db.version(1).stores({
  friends: 'name, age'
});
db.version(2).stores({
  friends2: '++id, name, age'
}).upgrade (tx => tx.friends.toArray().then(friends => {
  // As a part of renaming the table,
  // copy it to the new table friends2:
  return tx.friends2.bulkAdd(friends);
}));
db.version(3).stores({
  friends: null // delete friends table
})

What Did Not Work Before

In all previous versions of Dexie, upgraders could never access a table that was being deleted, even if it was being deleted in a later version than what the upgrade() was attached to. The upgrade() callback would fail due to missing table, as the table was already non-existing from the API point-of-view. So the upgrader in the above sample would fail with "NotFoundError Table 'friends' is does not exist".

IMPORTANT NOTICE

In order to access "death-sentenced tables" from an upgrader, it MUST access it through given upgrade transaction, and not just the global Dexie instance db.friends. A good practice henceforth is to always use the upgrade transaction, generally from upgrade callbacks. This is also backward compatible (Upgraders has always had the upgrade transaction as an argument, but it was not required to use it). Documentation of how to write upgraders are updated so that every upgrade() sample in the docs now use the given transaction instance.

Improved Node support

A lot of effort has been made to fix issues in Dexie when running on node (using IndexedDBShim. We're still seeing issues along the unit tests when running on node. One pull-request for IndexedDBShim has also been made. We're still not experiencing full IndexedDB compatibility on node though due to some remaining test failure of the dexie test suite when it runs on node (#709).

Improved Tests

Updated supported browsers to later versions (d2c24f4)
This release was successfully tested on the following browsers:

  • Firefox 47
  • Firefox 59
  • Edge 13
  • Edge 17
  • IE 11
  • Chrome 49
  • Chrome 66
  • Safari 10.1

Why still in Alpha?

In Dexie 3.0.0-alpha.1, all code was migrated to Typescript + splitted into smaller modules. The feature set is still almost identical to the stable 2.x version and is tested as rigorously. However, as the changes made to the code base were so large, I thought is was safe to increase the major version. Also, the d.ts files are completely rewritten, which implies breaking changes for Typescript users.

Until issue #659 is solved in one or other way, we will still be in alpha. If you experience problems using the library from your typescript code, please comment on #659. If you have ideas on how to fix it, please PR!


David Fahlander

Don't miss a new Dexie.js release

NewReleases is sending notifications on new releases.