1 | # Breaking changes in 8.x
|
2 |
|
3 | - Finally dropped support for old EdgeHTML engine.
|
4 | - Dropped support for browsers that don't support [`cursor.request`](https://caniuse.com/mdn-api_idbcursor_request).
|
5 | - Removed separate async iterators build. It's now one build with async iterator support.
|
6 |
|
7 | # Breaking changes in 7.x
|
8 |
|
9 | - No longer committing `build` to GitHub.
|
10 | - Renamed files in dist.
|
11 | - Added conditional exports.
|
12 | - iife build is now a umd.
|
13 |
|
14 | # Breaking changes in 6.x
|
15 |
|
16 | Some TypeScript definitions changed so write-methods are missing from 'readonly' transactions. This might be backwards-incompatible with code that performs a lot of type wrangling.
|
17 |
|
18 | # Breaking changes in 5.x
|
19 |
|
20 | I moved some files around, so I bumped the major version for safety.
|
21 |
|
22 | # Changes in 4.x
|
23 |
|
24 | ## Breaking changes
|
25 |
|
26 | ### Opening a database
|
27 |
|
28 | ```js
|
29 | // Old 3.x way
|
30 | import { openDb } from 'idb';
|
31 |
|
32 | openDb('db-name', 1, (upgradeDb) => {
|
33 | console.log(upgradeDb.oldVersion);
|
34 | console.log(upgradeDb.transaction);
|
35 | });
|
36 | ```
|
37 |
|
38 | ```js
|
39 | // New 4.x way
|
40 | import { openDB } from 'idb';
|
41 |
|
42 | openDB('db-name', 1, {
|
43 | upgrade(db, oldVersion, newVersion, transaction) {
|
44 | console.log(oldVersion);
|
45 | console.log(transaction);
|
46 | },
|
47 | });
|
48 | ```
|
49 |
|
50 | - `openDb` and `deleteDb` were renamed `openDB` and `deleteDB` to be more consistent with DOM naming.
|
51 | - The signature of `openDB` changed. The third parameter used to be the upgrade callback, it's now an option object which can include an `upgrade` method.
|
52 | - There's no `UpgradeDB` anymore. You get the same database `openDB` resolves with. Versions numbers and the upgrade transaction are included as additional parameters.
|
53 |
|
54 | ### Promises & throwing
|
55 |
|
56 | The library turns all `IDBRequest` objects into promises, but it doesn't know in advance which methods may return promises.
|
57 |
|
58 | As a result, methods such as `store.put` may throw instead of returning a promise.
|
59 |
|
60 | If you're using async functions, there isn't a difference.
|
61 |
|
62 | ### Other breaking changes
|
63 |
|
64 | - `iterateCursor` and `iterateKeyCursor` have been removed. These existed to work around browsers microtask issues which have since been fixed. Async iterators provide similar functionality.
|
65 | - All pseudo-private properties (those beginning with an underscore) are gone. Use `unwrap()` to get access to bare IDB objects.
|
66 | - `transaction.complete` was renamed to `transaction.done` to be shorter and more consistent with the DOM.
|
67 | - `getAll` is no longer polyfilled on indexes and stores.
|
68 | - The library no longer officially supports IE11.
|
69 |
|
70 | ## New stuff
|
71 |
|
72 | - The library now uses proxies, so objects will include everything from their plain-IDB equivalents.
|
73 | - TypeScript support has massively improved, including the ability to provide types for your database.
|
74 | - Optional support for async iterators, which makes handling cursors much easier.
|
75 | - Database objects now have shortcuts for single actions (like `get`, `put`, `add`, `getAll` etc etc).
|
76 | - For transactions that cover a single store `transaction.store` is a reference to that store.
|
77 | - `openDB` lets you add callbacks for when your database is blocking another connection, or when you're blocked by another connection.
|
78 |
|
79 | # Changes in 3.x
|
80 |
|
81 | The library became a module.
|
82 |
|
83 | ```js
|
84 | // Old 2.x way:
|
85 | import idb from 'idb';
|
86 | idb.open(…);
|
87 | idb.delete(…);
|
88 |
|
89 | // 3.x way:
|
90 | import { openDb, deleteDb } from 'idb';
|
91 | openDb(…);
|
92 | deleteDb(…);
|
93 | ```
|