Skip to content

Releases: dexie/Dexie.js

Dexie v4.0.1-beta.1

18 Oct 11:05
Compare
Choose a tag to compare
Dexie v4.0.1-beta.1 Pre-release
Pre-release

dexie@4.0.1-beta.1

  • Added missing declaration of Dexie.debug: 27ce021
  • Bugfix: Support single values compound keys: 93ea5eb
  • Bugfix: Provided tx argument to db.transaction() callback would not respect the transaction if db was vip. 2325178
  • liveQuery with cache enabled: signal subscribers outside the async context c6b40bd

dexie-cloud-addon@4.0.1-beta.48

  • Implementation of the new subscription model https://medium.com/dexie-js/dexie-cloud-subscription-model-cbf9a709ce7
  • Updated dexie-cloud-todo-app sample with license eval expiration alert.
  • Support for logout API instead of having to delete or clear the database: db.cloud.logout().
  • Support for logging in another user without logging out the current one (in db.cloud.login())
  • Other fixes and improvements of dexie-cloud-addon.
  • Allow expired eval users to pull down data but not to push.
  • Treat expired eval users as being forever offline (may still use app but without sync) until they are upgraded to prod by the database admin.
  • Remove console logs from the production build.
  • Default OTP GUI: Auto-submit OTP when 8 characters are pasted or written.
  • Bugfix: Syncing failed if table had inbound compound keys (#1777)
  • Handle API-Rate-limits gracefully, avoiding 429 responses by slowing down sync calls when less than 50% of remaining rate-limit are available. 3c4e698
    New dexie-cloud option: disableEagerSync

To install / upgrade:

npm i dexie@next
npm i dexie-cloud-addon@latest

Dexie v4.0.1-alpha.25

16 Jul 11:08
Compare
Choose a tag to compare
Dexie v4.0.1-alpha.25 Pre-release
Pre-release

PR #1766: Dexie Cloud stuck in login-phase if option {requireAuth: true} was used to db.cloud.configure()

The fix is generic in dexie libary for db.on('ready') callbacks so that the Dexie instance passed to the callback can be used without blocking.

Background:

When the on('ready') callback executes, the ready state shall still not be resolved because any on-ready subscriber's flow is part of making the db ready to resume application queries. But the callback itself need exclusive access before application queries resume - otherwise any db call will block like if it was an application-made db call. This works fine and has been working fine since dexie@2, but has been exclusively based on an async context that spans over the entire flow of db-on-ready callbacks. However, some on-ready callbacks (specifically dexie-cloud's) need to do calls outside of Dexie - such as fetch() calls - those calls will loose the AsyncContext and thus the exclusive access to the db. Therefore, we're now providing a Dexie instance as argument to the on-ready callback - an instance that can call dexie exclusively regardless of the async context. However, a bug prevented this from functioning properly until this release.

Dexie v4.0.0-alpha.24

06 Jul 14:14
Compare
Choose a tag to compare
Dexie v4.0.0-alpha.24 Pre-release
Pre-release

Fixes #1760: ReadonlyError: Write transactions not allowed within liveQueries

Dexie v4.0.1-alpha.23

04 Jul 22:49
Compare
Choose a tag to compare
Dexie v4.0.1-alpha.23 Pre-release
Pre-release

Bug fixes

  • dexie-cloud-addon: Behave when resetting database without reloading page. c3705a7

  • dexie: Fix #1736 Optimistic cache not purged on database deletion

Dexie v4.0.1-alpha.22

14 Jun 22:50
Compare
Choose a tag to compare
Dexie v4.0.1-alpha.22 Pre-release
Pre-release

General bugfixes

  • #1740 Where-clauses with object-syntax fail to reuse virtual indexes - (there's a corresponding fix in the 3.x track)

Bugfixes for cache and optimistic updates

  • Unhandled AbortErrors in console log (#1743)
  • Improvements of optimistic updates (#1733)
  • Move cache-middleware to level 0 (#1744)

Thanks to everyone that tried out 4.0.1-alpha.17 and found the issues that are now fixed!

Dexie v4.0.1-alpha.17

01 Jun 18:31
Compare
Choose a tag to compare
Dexie v4.0.1-alpha.17 Pre-release
Pre-release

This release replaces 4.0.1-alpha.12, 4.0.1-alpha.13 and 4.0.1-alpha.14 due to issues #1730, #1731 and a few other issues fixed in PR #1733

Cache and Optimistic Updates (v0.1)

The biggest news with this release is the initial support for common cache for live queries that enables multiple liveQuery observables targeting the same set of queries to reuse a single request towards indexedDB and to be immediately triggered as soon as data is being mutated. In practice, this will become a big game changer for large apps that has many ongoing liveQueries going on targeting large amount of data and possibly targeting the same data from different components.

Before the flow was pretty simple but could take some time from a mutation until a change was visible in the app if the app had many components using liveQuery and where the results of the queries were large.

Flow prior to this relase:

  1. All live queries for the app is run initially (and the components are rendered).
  2. User does som action so that data is being updated (such as db.friends.update(1, {age: 23}).
  3. Write-transaction is committed --> onstoragemutated event is broadcasted to all tabs and workers
  4. liveQueries that has touched the affected ranges are re-executed. If we have 10 components with affected liveQueries, all 10 of them will simultanously query IndexedDB for their data again.

Flow with this release:

  1. All live queries for the app is run initially their promises are immediately cached in memory so that several liveQueries requesting the same data will await the same single promise instead of each one of them requesting indexedDB. When result arrives, the result is kept in the cache as long as there are components subscribing to the query.
  2. User does som action so that data is being updated (such as db.friends.update(1, {age: 23}). The cache is immediately recomputed by applying the mutation to the previous result and triggering subscribers immediately to rerender.
  3. Mutation promise resolves or reject. If it rejects, the optimistic update is rolled back and components rerender.
  4. Transaction commits or rejects. If it rejects, the optimistic updates are rolled back and components rerender. If it was successful, components doesn't need to requery indexedDB because they already have the changes in the cache.
  5. All mutations are still broadcasted to other tabs and workers. When a mutation comes from another tab or worker, it will not be optimistic but require a re-execution of the query.

So basically, liveQueries will only request IndexedDB at startup and two identical queries will only result in a single query towards IndexedDB.

Now this is the initial version of this and only certain queries can utilize this:

  • If your liveQuery callback explicitely does db.transaction('r', ...), the user expects isolation, so optimistic updates won't be used.
  • Only simple range queries are supported in this initial version: equals, above, aboveOrEqual, below, belowOrEqual, between, startsWith.
  • Only tables with inbound keys are supported.
  • Only toArray() queries (not .keys(), .primaryKeys() or .count())
  • Not offset based queries.
  • Not ignoreCase queries
  • Not anyOf or inAnyRange

Example of optimised queries:

  • db.friends.toArray()
  • db.friends.where('age').between(18,65, true, true).limit(10).toArray()

Example of non-optimized queries in this initial version:

  • db.friends.primaryKeys()
  • db.friends.count()
  • db.friends.offset(25).toArray()
  • db.transaction('r', db.friends, () => db.friends.toArray())

PRs:

  • #1718 Optimistic updates
  • #1727 Fix optimistic updates

Other changes:

  • Dexie will throw if trying to mutate data from a liveQuery callback ( liveQuery(()=>db.friends.add({...})) )
  • A new constructor option to Dexie is {cache: 'immutable' | 'cloned' | 'disabled'}. The default is 'cloned' but 'immutable' would give better performance because the cached results can be returned directly to the caller without having to deep clone it. However, the data will be frozen so if the liveQuery callback would try to set properties or call mutating array operations on the results, it will fail to do so if having { cache: 'immutable' }. array.sort() is one example of a commonly used mutable operation. Workaround is to use array.slice().sort() instead.

Other PRs in this release

  • #1711 Add .d.mts files to support import types properly.
  • #1716 Remove custom unhandledrejection event propagation

Dexie v4.0.1-alpha.14

31 May 13:57
Compare
Choose a tag to compare
Dexie v4.0.1-alpha.14 Pre-release
Pre-release

This release is replaced by 4.0.1-alpha.17

Dexie v4.0.1-alpha.12

30 May 22:15
Compare
Choose a tag to compare
Dexie v4.0.1-alpha.12 Pre-release
Pre-release

This release is replaced by 4.0.1-alpha.17

Dexie v3.2.4

30 May 21:07
Compare
Choose a tag to compare

Fixes in this maintenance release:

  • #1728 Make the optimisation in dexie-react-hooks@1.1.5 work with dexie@3.x. In the latest version of dexie-react-hooks (version 1.1.5), live queries are optimised to not fire of unnecessary on render. However, this optimisation is dependant on that the observable returned from liveQuery has a method revealing whether it may be resolved synchronously or not (hasValue()). The optimisation requires dexie@>=3.2.4 or dexie@4.0.1-alpha.12 together with dexie-react-hooks@1.1.5.
  • #1677 Add //# sourceMappingUrl= to minified files. Fixes #326.
  • #1712 Add .d.mts files to support import types properly in preparation for future typescript release where this might be needed.

Dexie v4.0.1-alpha.10

28 Mar 22:47
Compare
Choose a tag to compare
Dexie v4.0.1-alpha.10 Pre-release
Pre-release

Better SSR support for NextJS and SvelteKit

This release (and related dexie-react-hooks release) comes with better behavior of liveQuery(). useLiveQuery() and useObservable() in SSR environments, as it makes sure that calling these from a node runtime without any indexedDB envirnomnent will result in a no-op. The result: Use these tools the same in Next.js as in vanilla React and in SvelteKIT as in vanilla Svelte - no need to check for SSR in application code anymore and no need to dynamically imported components doing dexie queries.

We also fixed the typings of our Observables returned from liveQuery() to be type-compatible with Svelte Readables (this was an issue when consuming liveQuery() results in Svelte using typescript).

Svelte users should install this prerelase of dexie instead of the stable version, but NextJS users may stay on the stable version of dexie if they prefer, and just upgrade dexie-react-hooks.

Full Next.js Support

  • Fixed more node errors that prevented nextjs SSR 19cdf0b
  • Better nextjs support for useLiveQuery(): 39484a3
  • Allow normal import of dexie-cloud-addon in nextjs: e18ee07

Full SvelteKit Support

Other fixes

  • Fix transaction typings #1685

We've also released...

dexie-react-hooks@1.1.3

  • Better nextjs support for useLiveQuery(): 39484a3

dexie-cloud-addon@4.0.1-beta.33

  • move rxjs deps out from peerDependencies and into ordinary dependencies
  • #1675 Dexie Cloud and NextJS improvements
  • #1691 Sveltekit fixes

dexie-export-import@4.0.7

  • progressCallback Problem? #1678