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