Dexie.js

A Minimalistic Wrapper for IndexedDB

APACHE-2.0 License

Downloads
2.2M
Stars
10.7K
Committers
98
Dexie.js - Dexie v3.0.0-alpha.2

Published by dfahlander over 6 years ago

PR #670: updating hook's onsuccess will get the updated object as documented, instead of the primary key.

PR #672: fix for setByKeyPath when removing array items

Dexie.js - Dexie v2.0.2

Published by dfahlander over 6 years ago

Fix: PR #670: updating hook's onsuccess will get the updated object as documented, instead of the primary key.

Dexie.js - Dexie v3.0.0-alpha.1

Published by dfahlander over 6 years ago

This is the first release after refactored dexie to typescript (Announcement #622, PR #653).

In summary, everything should work the same as latest stable, version 2.0.1.

To install:

npm install dexie@next

Keeping it on new major due to the massive rewrite and possible backward incompatibilities in the typings file (should only concern typescript users though). The only 2 known incompatibilities are:

  1. When using dexie-relationships from a typescript perspective. It may not be able to declare the typings of extended table and collection methods correctly.
  2. Requires a newer Typescript version (2.6.1 tested) to understand the d.ts file.
Dexie.js - Dexie v2.0.1

Published by dfahlander about 7 years ago

Angular / Zonejs issue

  • "Maximum call stack exceeded" with Zonejs 0.8.18 #589

Performance issue

  • Performance issue of toArray() not using optimized getAll() (#591)
Dexie.js - Dexie v2.0.0

Published by dfahlander about 7 years ago

At last, we have version 2.0.0 out and it is way more tested, compliant and bug free than the old 1.x branch.

I would bore you if listing all details since the last stable release (version 1.5.1 in November 2016) so I'll try to summarize it with focus on the most interesting parts:

Support for native and transpiled async / await

  • Use async functions within database transactions without loosing track of current ongoing transaction.
  • Compatible with Typescript 2.x, 1.x and babel.
  • Compatible with even native async / await across all browser inluding Safari, Chrome, Edge and Firefox*. Firefox still suffers from this issue which makes native await calls loose the transaction. This is something that only can be adressed by the Mozilla team. NOTE: You can still do async/await within transactions and target Firefox - just make sure to not use native async/await, but transpile it to ES5 or ES6 using a transpiler such as Babel or Typescript!

IndexedDB 2.0 support

Unit tests of Binary Keys (IndexedDB 2.0 feature) has been fixed along with some issues in Dexie related to binary key support. Binary Keys are a more optimal way of storing binary data in IndexedDB. IndexedDB 2.0 supports any typed array (such as Uint8Array, Float64Array, etc) as well as ArrayBuffer to be indexed or used as primary key. Browsers that support IndexedDB 2.0 are: Firefox(*), Chrome, Opera and Safari.

(*) Firefox < 57 have an issue with using binary keys as primary keys. This issue was fixed recently and will be solved in Firefox 57 (a future release).

Native Safari (including Iphone) Support

Safari 10.1 is now at last fully IndexedDB compliant and part of the CI tests of Dexie. We run the Safari tests on an IPhone 7 device at browserstack.com. IndexedDBShim is no more needed when targeting latest version of Safari (10.1).

Full test matrix is now:

We use travis ci and browserstack for continous integration and automatic pre-relase tests. If you'd like to extend the test matrix, please file a PR where you add your desired browser to karma.browers.matrix.js. You must also define the browser in karma.browserstack.js. Submitting the PR will tell whether it would work or not (just add your new browser to the "ci" array of karma.browsers.matrix.js and define the same browser in karma.browserstack.js).

NOTE: Integration tests of dexie-observable, dexie-syncable and dexie-relationships are still not tested against the full matrix quite yet.

A pick of other news...

  • Dexie.waitFor() makes it possible to call non-indexedDB API:s (promise-returning async API:s!) without loosing the transaction.

  • Simpler queries like:

    await db.friends.where({
        name: "Bobby",
        age: 42
    }).toArray()
    

    will try using a compatible compound index [name+age] if present (and browser supports it), else just utilizing one of the indexes and JS-filter on the second criteriea.
    See Table.where()

  • Simpler way of getting a single row by index instead of primary key:

    const foo = await db.friends.get({email: '[email protected]'})
    

    See Table.get()

  • Improved typescript definitions in general

  • Much work has been put on rewriting and fixing issues in dexie-syncable and dexie-observable. Thanks @nponiros !

Backward Compatibility

Keeping backward compatibility is a number one priority for Dexie.js, so there are not a lot of API changes. However, some things need to change some time and a few API methods that have been deprecated for a time have gone obsolete. The full list can be viewed here: http://dexie.org/docs/Deprecations

Dexie.js - Version 2.0.0-rc.1

Published by dfahlander about 7 years ago

This is a stability release with:

  • Improved browser support (latest Safari, Firefox and Chrome)
  • IndexedDB 2.0 support
  • Typings fixes
  • Optimization of addon dexie-syncable.

We will try to get out a 2.0.0 version very soon, as this branch feels way more stable and reliable than the 1.x branch (that is currently still marked as 'latest' on npm).

Native Safari Support

Safari 10.1 is now at last fully IndexedDB compliant and part of the CI tests of Dexie. We run the Safari tests on an IPhone 7 device at browserstack.com. IndexedDBShim is no more needed when targeting latest version of Safari (10.1).

Full test matrix is now:

We use travis ci and browserstack for continous integration and automatic pre-relase tests. If you'd like to extend the test matrix, please file a PR where you add your desired browser to karma.browers.matrix.js. You must also define the browser in karma.browserstack.js. Submitting the PR will tell whether it would work or not (if adding you new browser to the "ci" array of karma.browsers.matrix.js and defining the same browser in karma.browserstack.js).

NOTE: Integration tests of dexie-observable, dexie-syncable and dexie-relationships are not tested against the full matrix quite yet. Will see if we can improve that somehow before 2.0.0 final.

IndexedDB 2.0 support

Unit tests of Binary Keys (IndexedDB 2.0 feature) has been fixed along with some issues in Dexie related to binary key support. Binary Keys are a more optimal way of storing binary data in IndexedDB. IndexedDB 2.0 supports any typed array (such as Uint8Array, Float64Array, etc) as well as ArrayBuffer to be indexed or used as primary key. Browsers that support IndexedDB 2.0 are: Firefox(*), Chrome, Opera and Safari.

(*) Firefox < 57 have an issue with using binary keys as primary keys. This issue was fixed recently and will be solved in Firefox 57 (a future release).

List of PRs since 2.0.0-beta.11

  • #540 Fix typing for .on('ready')
  • #534 Make hook callbacks compatible with typescript noImplicitThis option
  • #570 Change apply-changes to use a transaction to manage changes instead of using chanined promises.
  • #579 Workaround for Safari issue with getAll()
  • #580 Fix typescript (type error) on adding addons
  • #581 Fix IndexedDB 2.0 flaws in Dexie and make unit tests of binary keys work.
  • #583 Include Safari and smartphones in test suite and fix Dexie bugs and -workarounds for making Safari work fully with Dexie.
Dexie.js - Dexie v2.0.0-beta.11

Published by dfahlander over 7 years ago

Fixes

  • Fixed bower config to meet best practices (#488) #490

  • Typings (d.ts) correction of Dexie.exists() and Dexie.delete()#497

  • Bubble up QuotaExceededError instead of AbortError: Transaction aborted #514

    Fixes #323

    Rather than throwing Unhandled rejection: AbortError: Transaction aborted when the user is out of disk space, the underlying transaction error (QuotaExceededError) is bubbled up. This allows consumers of the Dexie API to identify QuotaExceededErrors and handle them accordingly.

    NOTE: I used http://www.cylog.org/utilities/filldisk.jsp to fill up my hard disk to try this code locally.

  • Update typescript Promise definition #518
    Dexie.Promise typings needed adjustments to compile correctly with tsc > v2.3.

Breaking Change

  • Don't use IndexedDBShim just because it's included #511
    Resolves #342 and #148

    This change is a breaking change (though to the better), since the shim will no more be used on browsers where it's not needed. We need to collect some user feedback about how this affects apps. What we know is that we now go over letting the shim to its job to detect whether it should be applied or not. To be backward compatible, call shimIndexedDB.__useShim(); before including dexie.

Dexie.js - Dexie v2.0.0-beta.10

Published by dfahlander over 7 years ago

Changes since 2.0.0-beta.9

Bugs

Features

New Feature #447 (concerns dexie-syncable addon)

  • dexie-syncable (now at version 1.0.0-beta.3): Possible to change option for a connected node (via db.syncable.connect())
  • db.syncable.getOption() added to get the options of a connected node 146950c 6caf09b

Build process

  • dexie-syncable: Add missing tests to unit tests and CI inclusion 1f6054b
Dexie.js - Dexie v2.0.0-beta.9

Published by dfahlander over 7 years ago

Much work has been done in this release with dexie-syncable and dexie-observable thanks to @nponiros. Versions 1.0.0-beta.2 of these addons were released together with this dexie-release.

News since 2.0.0-beta.7

  • Stability fixes for dexie-observable and dexie-syncable
  • The source files of Dexie.Syncable and Dexie.Observable are splitted into smaller modules.
  • Lots of new unit tests for dexie-syncable and dexie-observable. Now travis runs integration- and unit tests for the addons as well.
  • Partial tresholds configurable for dexie-syncable (#423)
  • Fixes for the ajax sync protocol (#424)
  • Refactor Dexie.Syncable tests and added new ones (#426)
  • Eslinting Dexie.Syncable and Dexie.Observable.
  • Added typings tests for dexie-syncable.d.ts and dexie-observable.d.ts
  • Fix for typescript strictNullChecks=true (#448)

Build Scripts

  • Switched from babel to typescript for compilation. Still plain JS, but typescript transpiles it nicer than babel.
  • Threw away all custom build scripts and now using plain CLI command via just-build
  • Integration- and unit tests for addons now part of the travis CI.

Other

  • Excellent React and Angular2 samples (#417, #418) by @nponiros
Dexie.js - Dexie v2.0.0-beta.7

Published by dfahlander almost 8 years ago

Stability for dexie-syncable

A lot of work has been put into dexie-observable and dexie-syncable to fix stability issues and generate typescript definition files for them. We are continuing to improve these addons and approach version 1.0 of them.

The addons have been updated at npm as well and we strongly encourage to upgrade the addons if going up on this version of Dexie.

npm install [email protected]
npm install [email protected]

List of fixes.

  • Review and bugfix dexie-observable and dexie-syncable (#393)
  • Make dexie typings extendable by addons (#398)
  • Stop using localStorage for recording database names for Dexie.getDatabaseNames() (#399)
  • Resolves #389. Also update Promise interface. (#394)
  • Resolves #386
  • Resolves #387
  • Upgrade QUnit (#384)
  • fix382 (#383) resolves #382.
  • Typings for dexie-observable and dexie-syncable (Resolves #213)
  • Various fixes 2016 12 21 (#412)
Dexie.js - Dexie v2.0.0-beta.6

Published by dfahlander almost 8 years ago

Updated dexie.d.ts with Dexie.waitFor() (#382)

Dexie.js - Dexie v2.0.0-beta.5

Published by dfahlander almost 8 years ago

More rigorously release notes to come...

To take is short:

New methods:

  • Dexie.waitFor() makes it possible to call non-indexedDB API:s (promise-returning async API:s!) without loosing the transaction
  • Table.get({name: "David", age: 43});
  • Table.where({firstName: "David", lastName: "Beckham"});
  • other fixes. Will list soon. If you're impatient, look in the commit history

Note: Dexie.Observable and Dexie.Syncable must be updated to version 0.2.1 to work with this version of Dexie.

Dexie.js - Dexie v2.0.0-beta.4

Published by dfahlander almost 8 years ago

Bugfixes

  • #360 - stability fix.

Features

  • Improved support for async / await inside transactions. Have tested that async/await can be used within transaction scopes in the following configurations:
    • Babel
    • Typescript 2.1
    • Natively in Edge 14 ( with experimental javascript flags on )
    • Natively in Chrome 55 beta.

Changed Behavior

PrematureCommitError

PrematureCommitError makes it visible when you accedently fall outside the transaction zone and start using the database transactionless without knowing so.

Before, if you'd use a non-Dexie Promise and then continue using database after that, you wouldn't detect that your code runs outside the transaction and the code could succeed silently without you noticing it did stuff transactionless.

Now, if the indexedDB transaction commits before your returned promise is completed, PrematureCommitError will be thrown. That is; if you for example await jQuery.ajax() within your transaction block, the transaction will now fail with PrematureCommitError. In earlier releases, it would sometimes fail with TransactionInactiveError() when this occurred, but only if the zone persisted when trying to do another db call.

Dexie.js - Dexie v1.5.1

Published by dfahlander almost 8 years ago

Stability bugfix of #360.

Dexie.js - Dexie v2.0.0-beta.3

Published by dfahlander about 8 years ago

  • Improved typescript definition for hooks (#348) (Should resolve #346 and #347)
  • AbortError when utilizing Table.mapToClass() on class with readonly properties (Cherry-pick of e0564cc40f9ded45f4b361c098f967d556b7c2e9 from v1.5.0)
Dexie.js - Dexie v1.5.0

Published by dfahlander about 8 years ago

News

This release is the first maintainence release of Dexie v1.x as version v2.0-beta is being developed on the master branch in parallell. Dexie v1.x is being maintained continously in parallell with the development of 2.x on the master-1 branch.

Support for 'unhandledrejection' event

It's incredibly easy to forget catching promises. The HTML standard has evolved to support a global 'unhandledrejection' event to make sure no error goes unseen for the developer. Dexie 1.5 now supports and embraces the use of this event instead of the previous custom Dexie.Promise.on('error', ...).

window.onunhandledrejection = function (event) {
    var reason = event.reason;
    console.warn('Unhandled Promise Rejection: ' + (reason && (reason.stack || reason));
    event.preventDefault(); // Prohibit default handler from logging to console.
};

Works also with window.addEventListener('unhandledrejection', ...);

Works on legacy browsers as well (Tested on IE11, Firefox 45, Edge 13 and Chrome 49).

Search your code for Promise.on('error, Promise.on("error or Promise.on.error to see if you should go over to the standard way instead. I've deprecated Promise.on.error but it will continue to work in 1.x. In 2.0 it's obsolete.

Bugfixes

Build- and deployment tools

  • Upgrading build and transpiler tools
  • Prepared for supporting maintainance releases on 1.x branch while continuing to develop Dexie v2.x.

Deprecations (See https://github.com/dfahlander/Dexie.js/wiki/Deprecations)

  • Transaction.table (will be continously supported in 2.x as well)
  • Transaction.[table] (will be continously supported in 2.x as well)
  • Transaction.tables (will be continously supported in 2.x as well)
  • Transaction.error (will be obsolete in 2.x)
  • Transaction.complete (will be obsolete in 2.x)
  • Dexie.Promise.on('error', ...) (Will be obsolete in 2.x)
Dexie.js - Dexie v2.0.0-beta.2

Published by dfahlander about 8 years ago

First beta-release of the 2.0 track.

Support for async functions (native and transpiled)

  • Typescript 2.0 compatible async await within transactions without quirks.
  • Compatible with the native async await in Edge 14 and Chrome 53 (with experimental flags on)
  • Should be compatible witht transpiled async await using babel (not verified yet)
  • Should be compatible with Angular2 and Zone.js when using typescript's transpiled async functions (not verified yet)

No need to 'stick to Dexie.Promise'

Native (or polyfilled) Promise can be safely used within transaction scopes. So for example, the use of Promise.all(...) would break transaction in Dexie v1.x but works perfectly well in Dexie v2.x without having to do Dexie.Promise.all(...). We're solving the browser-issues described in #317 by polyfilling the global Promise to play well with indexedDB transactions within the transaction scope only, and revert the patching for every leave from the transaction scope. This is possible only because of the built-in zone system that Dexie has.

Prepared to retire Dexie.Promise in a future major version

Dexie v2.x will keep using Dexie.Promise, but the work needed retire Dexie.Promise in favour of native Promise has been implemented, and once the problem described in #317 is fully solved widely by the affected browsers (IE, Safari and Firefox) we will do that shift. In the meantime, I've started the mounting down of Dexie.Promise-specific API:s so that the user shouldn't have to think about Dexie.Promise anymore. Code will look the same as soon as we do the switch to native Promise.

Breaking Changes / Backward Compatibility

Dexie 2.0 is built with backward compatibility in mind, but there are a few things that you would might need to fix before migrating:

  1. Dexie.Promise.on('error') is deprecated in Dexie 1.5.0 and obsolete in Dexie 2.0.0. Deprecation notes
  2. db.on('error') is deprecated in Dexie 1.5.0 and obsolete in Dexie 2.0.0. Deprecation notes

A full story of obsolete parts of the API is listed in the wiki under Deprecations. Note that some of the deprecations are still available in 2.0 but are planned to go obsolete in 3.0.

The main reason for the major version increment, else than the obsolete methods, is the new way that db.transaction() works - specifically that it patches the global promise within the transaction zone, wich is a change of a behavior in an existing API. db.transaction() is still backward compatible though and you don't need to change your transaction code.

Dexie.js - Dexie v1.5.0-rc.2

Published by dfahlander about 8 years ago

Deprecating Promise.on.error and added support for the global unhandledrejection event. Subscribe to the unhandledrejection event instead. This is the standard way of catching unhandled native promise rejections as well.

Dexie.js - Dexie v1.5.0-rc

Published by dfahlander about 8 years ago

Minor version was incremented due to deprecation of APIs (see notes below). Note that those API:s still work and most of them will continue to work also in Dexie 2.x.

Bugfixes:

  • Fixes #326 Broken sourceMappingURL for dexie.min.js

Build- and deployment tools

  • Upgrading build and transpiler tools
  • Prepared for supporting maintainance releases on 1.x branch while continuing to develop Dexie v2.x.
  • Avoiding cyclic dependencies in ES6 source

Deprecations (See https://github.com/dfahlander/Dexie.js/wiki/Deprecations)

  • Transaction.table (will be continously supported in 2.x as well)
  • Transaction.[table](will be continously supported in 2.x as well)
  • Transaction.tables (will be continously supported in 2.x as well)
  • Transaction.error (will be obsolete in 2.x)
  • Transaction.complete (will be obsolete in 2.x)
Dexie.js - Dexie v1.4.3-rc

Published by dfahlander about 8 years ago

Resolved issues:

  • Issue with '?' transaction mode c9e1384df72aca5344bc6c825fec8ed73f7e9359
  • #310 Problems including dexie using rollup 8e1beff6446cd51d686a9db49ff0ccd644826822

Also:

  • Replace npmcdn.com with unpkg.com 5fe9c3a0a6d563f7991ff45b7822a0fd4a73f3b2