Dexie.js

A Minimalistic Wrapper for IndexedDB

APACHE-2.0 License

Downloads
2.2M
Stars
10.7K
Committers
98
Dexie.js - Dexie v3.0.3-rc.3

Published by dfahlander about 4 years ago

Bugfix of #1148 (PR #1149).

Dexie.js - Dexie v3.0.3-rc.2

Published by dfahlander about 4 years ago

Another Release Candidate

Please help me test this release candidate that contains various fixes and improvements. It's released with the "next" tag on npm instead of "latest". Will release it with the "latest" tag after a week unless someone finds backward compability issues or regression bugs.

npm i [email protected]

New fixes since 3.0.3-rc.1

  • #1146: Resolve #1145 Regression: SchemaError during version upgrade
  • #1138: Dexie.Observable: startObserving function: remove read-only query in order to avoid TransactionInactiveError
  • #1136: Allow declaration-only tables for TS users

Dexie-observable & dexie-syncable are on version 3.x now

This regards to the previous release candidate as well: You need to upgrade dexie-observable and dexie-syncable if you have them, to their latest major versions.

npm i [email protected] [email protected]
Dexie.js - Dexie v3.0.3-rc.1

Published by dfahlander about 4 years ago

Release Candidate

Please help me test this release candidate that contains various fixes and improvements. It's released with the "next" tag on npm. Will release it with the "latest" tag after a week or two unless someone finds backward compability issues or regression bugs.

npm i [email protected]

Typing fixes

  • Fix Table.bulkGet return typing to include undefined #1098
  • Allow readonly arrays for bulk put & get methods #1106
  • Use error keys insted of values for typescript #1115

Improvements

  • Verify schema on open #1108
  • Repro + resolve issue #1112: typescript declaration of id makes autoInc fail #1119

Bugfixes

  • Allow middleware hooks to return objects that contained field names that contain dotted strings #1130
  • Resolve #1127 #1131

Addons

  • Issue 1048 Typings of addons for Dexie 3.0 #1117
    The addons are released with the "next" tag on npm, so please test them and help me verify that #1048 is solved:
    npm i [email protected]
    npm i [email protected]
    
Dexie.js -

Published by dfahlander about 4 years ago

PRs:

  • #1062: Typing fix for Dexie.Observable IDatabaseChange.
  • #1081: Run reading hooks in bulkGet
  • Updated dev-dependencies
Dexie.js - Dexie v3.0.1

Published by dfahlander over 4 years ago

Maintainance Release

Changes

Bug fixes

  • #791 Dexie.Observable: Cannot read property 'indexOf' of null
  • #1039 Table named 'schema' not working in Dexie 3

Other

Dexie.js - Dexie v3.0.0

Published by dfahlander over 4 years ago

CSP compliance

Dexie is now CSP compliant (#722)

Improved Database Upgrading

It is no longer needed to keep old versions of schemas unless they have an upgrade attached. This is explained in release notes from 3.0.0-rc.3. The docs are updated accordingly.

Also, an old issue with upgrades has been that it was impossible to copy contents from one table to a new one and then remove the old one. This is now fixed, see release notes from [3.0.0-alpha.3] (https://github.com/dfahlander/Dexie.js/releases/tag/v3.0.0-alpha.3))

Typescript

Dexie has been refactored to using Typescript (Announcement #622, PR #653).

Redesign

The big difference in this release from v2.0.4, is how we call IndexedDB. Instead of calling it directly, it will go through a middleware-enabled stack, DBCore.

NOTE: This is an internal redesign. The external API is still the same as in Dexie 2.0 so you won't have to adapt to the new possibilities that comes with this redesign, unless you want to use the new middleware api (Dexie.use()).

This rewrite is part of reaching the goals in vision for dexie, specifically it will enable asynchronic work to be done in a middleware, which is something covered in here.

See new documentation of Dexie.use()

Table.bulkGet()

In response to #833, Table.bulkGet() was added and is a more optimal way than WhereClause.anyOf() when what you need is to fetch several objects with known IDs. The documentation is here

Virtual Indexes

VirtualIndex makes it possible to use the first part of a compound index as if it was an ordinary index.
Dexie will emulate an ordinary index so that it will works with algorithms such as equalsIgnoreCase() etc.

Example:

const db = new Dexie("mydb");
db.version(1).stores({
  friends: '++id, [lastName,firstName]'
});

function findFriendByLastName(prefix) {
   // Note: You can use 'lastName' because it's the first part of a compound index.
   return db.friends.where('lastName').startsWith(prefix);
}

In earlier versions, you would have to specify 'lastName' index side by side with [lastName+firstName]

Issues and fixes since 2.0.4

  • 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
  • #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.
  • #771 Don't console.warn() unless Dexie.debug is truthy
  • #768 Issues with Collection.raw and Table.mapToClass
  • #612 Native async/await and upgrade handlers
  • #770 Using a database in an upgrade handler prevents subsequent upgrade handlers from running
  • Bugfix for extracting index spec for handling dynamically opened outbound primkeys (commit 9718d95d9b3a434749079a7217412b8c9917c0e6)
  • #811 Dexie does not run under ESNext in Node
  • Fixed CSP compliance (#722)
  • Fixed bug that omitted changes of properties with non-primitive intrinsic types (Date, ArrayBuffer, etc) in call to update hook (#841)
  • Feature: optionally all keys are returned on Table.bulkAdd() and Table.bulkPut() methods (PR #973)
  • Fix for issue 947 (PR #948)
  • Fix #491 (Check that versions given to db.version() is a positive number.)
  • Support Promise.allSettled() and Promise.any() (runtime only. Typings still rely on Typescript lib to support it)
  • Resolves a bug that Dexie may come into a state when it is unable to open a db in case the db exists but has no ObjectStores in it.
Dexie.js - Dexie v3.0.0-rc.7

Published by dfahlander over 4 years ago

Resolves a bug that Dexie may come into a state when it is unable to open a db in case the db exists but has no ObjectStores in it.

Dexie.js - Dexie v3.0.0-rc.6

Published by dfahlander over 4 years ago

Resolves #1004

Getting closer to final release.

Dexie.js - Dexie v3.0.0-rc.5

Published by dfahlander over 4 years ago

Dexie.js - Dexie v3.0.0-rc.4

Published by dfahlander over 4 years ago

Reverting to async/await behavior as in [email protected] and dexie<3.0.0-beta.1 but still CSP compliant.

https://github.com/dfahlander/Dexie.js/commit/d02d999858eb9a449ce198b391db8849269d2cdb

Dexie.js - Dexie v3.0.0-rc.3

Published by dfahlander over 4 years ago

News:

  • PR #959 A very nice PR that makes it optional to keep older versions of schemas unless you have a migration (upgrader) on it. Also, which is the most important benefit with this PR, if the developer has declared an old version that is not accurate to the actual installed version, this would not harm anymore. Dexie will only rely on the actual installed version instead of inspecting the declared version. This will probably take away some headaches people have had getting UpgradeError: "Dexie specification of currently installed DB version is missing".

  • Issue #902 of dexie-export-import fixed by increasing the max buffer size for JSON strings from 64k to 10MB.

  • General dependency housekeeping

  • Fixed CI test assuring dexie and dexie-relationships will continously work together on every new Dexie version ahead.

  • Bumped version numbers for dexie-observable and dexie-syncable so that some typings corrections for them where released to npm.

Dexie.js - Dexie v3.0.0-rc.2

Published by dfahlander over 4 years ago

News:

  • Feature: optionally all keys are returned on Table.bulkAdd() and Table.bulkPut() methods (PR #973)
  • Fix for issue 947 (PR #948)
Dexie.js -

Published by dfahlander about 5 years ago

First beta release:

Features

Virtual Indexes

VirtualIndex makes it possible to use the first part of a compound index as if it was an ordinary index.
Dexie will emulate an ordinary index so that it will works with algorithms such as equalsIgnoreCase() etc.

Example:

const db = new Dexie("mydb");
db.version(1).stores({
  friends: '++id, [lastName,firstName]'
});

function findFriendByLastName(prefix) {
   // Note: You can use 'lastName' because it's the first part of a compound index.
   return db.friends.where('lastName').startsWith(prefix);
}

In earlier versions, you would have to specify 'lastName' index side by side with [lastName+firstName]

Most important bug fixes

  • Fixed CSP compliance (#722)
  • Fixed bug that omitted changes of properties with non-primitive intrinsic types (Date, ArrayBuffer, etc) in call to update hook (#841)
Dexie.js - Dexie v3.0.0-alpha.8

Published by dfahlander over 5 years ago

New Features

Table.bulkGet()

In response to #833, Table.bulkGet() was added and is a more optimal way than WhereClause.anyOf() when what you need is to fetch several objects with known IDs. The documentation is here

Fixes

  • #811 Dexie does not run under ESNext in Node
Dexie.js - Dexie v3.0.0-alpha.7

Published by dfahlander over 5 years ago

Latest fixes. TBD.

Dexie.js - Dexie v3.0.0-alpha.6

Published by dfahlander almost 6 years ago

Maintainance Release

This new release contains the latest fixes in master branch. I consider this release rather stable, despite the "alpha" status, which is due to that the new DBCore layer's API is still emerging.

This particular release does not contain any changes in DBCore from last alpha version.

Dexie-export-import

Although not part of the main npm package, one of the biggest news in the repository since last alpha version, is the new addon dexie-export-import which is already released as its own package on npm. That package can be used with either [email protected] or [email protected] stable.

Fixes

  • #771 Don't console.warn() unless Dexie.debug is truthy
  • #768 Issues with Collection.raw and Table.mapToClass
  • #612 Native async/await and upgrade handlers
  • #770 Using a database in an upgrade handler prevents subsequent upgrade handlers from running
  • Bugfix for extracting index spec for handling dynamically opened outbound primkeys (commit 9718d95d9b3a434749079a7217412b8c9917c0e6)
Dexie.js - Dexie v3.0.0-alpha.5

Published by dfahlander almost 6 years ago

Fixes

Redesign

The big difference in this release from v3.0.0-alpha.3, is how we call IndexedDB. Instead of calling it directly, it will go through a middleware-enabled stack, DBCore.

NOTE: This is an internal redesign. The external API is still the same as in Dexie 2.0 so you won't have to adapt to the new possibilities that comes with this redesign, unless you want to use the new middleware api (Dexie.use()).

This rewrite is part of reaching the goals in vision for dexie, specifically it will enable asynchronic work to be done in a middleware, which is something covered in here.

To use it in this version, do:

import Dexie from 'dexie';

const db = new Dexie('dbname');

db.use({
  stack: "dbcore", // The only stack supported so far.
  name: "MyMiddleware", // Optional name of your middleware
  create (downlevelDatabase) {
    // Return your own implementation of DBCore:
    return {
      // Copy default implementation.
      ...downlevelDatabase, 
      // Override table method
      table (tableName) {
        // Call default table method
        const downlevelTable = downlevelDatabase.table(tableName);
        // Derive your own table from it:
        return {
          // Copy default table implementation:
          ...downlevelTable,
          // Override the mutate method:
          mutate: req => {
            // Copy the request object
            const myRequest = {...req};
            // Do things before mutate, then
            // call downlevel mutate:
            return downlevelTable.mutate(myRequest).then(res => {
              // Do things after mutate
              const myResponse = {...res};
              // Then return your response:
              return myResponse;
            });
          }
        }
      }
    };
  }
});

As the DBCore interface is still being figured out, it can change. And there is still no official documentation about it. In essence, all mutating operations are bulk-oriented. Theres only bulkPut(), bulkAdd(), bulkDelete() and deleteRange(). Currently all of these four are reached through a single method mutate(). (This might change in future).

Interface definitions for DBCore is found here

In this version, the CRUD hooks are called from a built-in middleware: hooksMiddleware: A middleware that makes sure to call CRUD hooks in a backward compatible manner.

Dexie.js - Dexie v3.0.0-alpha.3

Published by dfahlander over 6 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 (https://github.com/dfahlander/Dexie.js/commit/d2c24f497886e1d75141ad386c66c9e3a096d8c8)
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

Dexie.js - Dexie v2.0.4

Published by dfahlander over 6 years ago

This patch release includes a bugfix: If disabling cookies in Firefox, Dexie.js failed to load (see PR #619).

Note that 2.x releases are now maintainance releases only and is backed by branch "master-2". The master branch maps to [email protected].

To install this release

npm install dexie

To install the very latest version,

npm install dexie@next
Dexie.js - Dexie v2.0.3

Published by dfahlander over 6 years ago

Maintainance release

This release fixes issue #617: SecurityError when storage is disabled (again)