A Minimalistic Wrapper for IndexedDB
APACHE-2.0 License
Published by dfahlander about 4 years ago
Bugfix of #1148 (PR #1149).
Published by dfahlander about 4 years ago
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]
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]
Published by dfahlander about 4 years ago
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]
npm i [email protected]
npm i [email protected]
Published by dfahlander over 4 years ago
Published by dfahlander over 4 years ago
Dexie is now CSP compliant (#722)
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))
Dexie has been refactored to using Typescript (Announcement #622, PR #653).
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()
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
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]
db.table.where({tags: 'browser', categories: 'database'})
.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.
Published by dfahlander over 4 years ago
Resolves #1004
Getting closer to final release.
Published by dfahlander over 4 years ago
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
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.
Published by dfahlander over 4 years ago
News:
First beta release:
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]
Published by dfahlander over 5 years ago
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
Published by dfahlander over 5 years ago
Latest fixes. TBD.
Published by dfahlander almost 6 years ago
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.
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.
Published by dfahlander almost 6 years ago
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.
Published by dfahlander over 6 years ago
db.table.where({tags: 'browser', categories: 'database'})
.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
})
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".
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.
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).
Updated supported browsers to later versions (https://github.com/dfahlander/Dexie.js/commit/d2c24f497886e1d75141ad386c66c9e3a096d8c8)
This release was successfully tested on the following browsers:
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
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
Published by dfahlander over 6 years ago
This release fixes issue #617: SecurityError when storage is disabled (again)