From 52b56b5c2cac3e40cdda97480335b0a09b7afda0 Mon Sep 17 00:00:00 2001 From: Muhammad Asif <55624875+AsifMahsud@users.noreply.github.com> Date: Fri, 2 Oct 2026 16:19:40 +0500 Subject: [PATCH 1/2] IDBDatabase: make the upgrade example work for existing databases --- files/en-us/web/api/idbdatabase/index.md | 53 ++++++++++++++---------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/files/en-us/web/api/idbdatabase/index.md b/files/en-us/web/api/idbdatabase/index.md index 2d203f8d8cb7aa6..d6b1a0cd87f93c6 100644 --- a/files/en-us/web/api/idbdatabase/index.md +++ b/files/en-us/web/api/idbdatabase/index.md @@ -55,11 +55,11 @@ The following events are available to `IDBDatabase` via event bubbling from {{do ## Example -In the following code snippet, we open a database asynchronously ({{domxref("IDBFactory")}}), handle success and error cases, and create a new object store in the case that an upgrade is needed (`IDBDatabase`). For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a database asynchronously ({{domxref("IDBFactory")}}), handle success and error cases, and create or update the object store in the case that an upgrade is needed (`IDBDatabase`). For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database -const DBOpenRequest = window.indexedDB.open("toDoList", 4); +const DBOpenRequest = window.indexedDB.open("toDoList", 2); // these two event handlers act on the IDBDatabase object, // when the database is opened successfully, or not @@ -69,7 +69,7 @@ DBOpenRequest.onerror = (event) => { }; DBOpenRequest.onsuccess = (event) => { - node.appendChild(document.createElement("li")).textContent = + note.appendChild(document.createElement("li")).textContent = "Database initialized."; // store the result of opening the database in the db @@ -82,7 +82,7 @@ DBOpenRequest.onsuccess = (event) => { }; // This event handles the event whereby a new version of -// the database needs to be created Either one has not +// the database needs to be created. Either one has not // been created before, or a new version number has been // submitted via the window.indexedDB.open line above @@ -94,25 +94,36 @@ DBOpenRequest.onupgradeneeded = (event) => { "Error loading database."; }; - // Create an objectStore for this database using - // IDBDatabase.createObjectStore - - const objectStore = db.createObjectStore("toDoList", { - keyPath: "taskTitle", - }); - - // define what data items the objectStore will contain - - objectStore.createIndex("hours", "hours", { unique: false }); - objectStore.createIndex("minutes", "minutes", { unique: false }); - objectStore.createIndex("day", "day", { unique: false }); - objectStore.createIndex("month", "month", { unique: false }); - objectStore.createIndex("year", "year", { unique: false }); - - objectStore.createIndex("notified", "notified", { unique: false }); + // event.oldVersion is the version the user already has: 0 if the + // database is being created for the first time. Apply each upgrade + // step the user hasn't had yet, so that both new users and users + // with an older version end up with the same database. + + if (event.oldVersion < 1) { + // Version 1: create an objectStore for this database using + // IDBDatabase.createObjectStore, and define what data items + // it will contain + const objectStore = db.createObjectStore("toDoList", { + keyPath: "taskTitle", + }); + + objectStore.createIndex("hours", "hours", { unique: false }); + objectStore.createIndex("minutes", "minutes", { unique: false }); + objectStore.createIndex("day", "day", { unique: false }); + objectStore.createIndex("month", "month", { unique: false }); + objectStore.createIndex("year", "year", { unique: false }); + } + + if (event.oldVersion < 2) { + // Version 2: add an index to the object store created in version 1. + // Calling createObjectStore() again here would throw, because the + // store already exists, so get it from the upgrade transaction + const objectStore = DBOpenRequest.transaction.objectStore("toDoList"); + objectStore.createIndex("notified", "notified", { unique: false }); + } note.appendChild(document.createElement("li")).textContent = - "Object store created."; + "Database upgraded."; }; ``` From b4ebcffb716b0ced57ac58928ab10e3aecd63266 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Tue, 13 Oct 2026 15:38:23 -0700 Subject: [PATCH 2/2] Add links everywhere --- files/en-us/web/api/idbdatabase/close/index.md | 3 ++- files/en-us/web/api/idbdatabase/close_event/index.md | 2 +- .../web/api/idbdatabase/createobjectstore/index.md | 3 ++- files/en-us/web/api/idbdatabase/index.md | 1 - files/en-us/web/api/idbdatabase/name/index.md | 7 +------ .../web/api/idbdatabase/objectstorenames/index.md | 3 ++- files/en-us/web/api/idbdatabase/transaction/index.md | 3 +-- files/en-us/web/api/idbdatabase/version/index.md | 3 ++- .../web/api/idbdatabase/versionchange_event/index.md | 2 +- files/en-us/web/api/idbfactory/index.md | 3 +-- files/en-us/web/api/idbfactory/open/index.md | 3 +-- files/en-us/web/api/idbobjectstore/add/index.md | 6 +----- .../web/api/idbobjectstore/autoincrement/index.md | 8 +------- files/en-us/web/api/idbobjectstore/clear/index.md | 6 +----- .../en-us/web/api/idbobjectstore/createindex/index.md | 7 +------ files/en-us/web/api/idbobjectstore/delete/index.md | 7 +------ .../en-us/web/api/idbobjectstore/deleteindex/index.md | 9 +-------- files/en-us/web/api/idbobjectstore/get/index.md | 8 +------- files/en-us/web/api/idbobjectstore/index.md | 3 +-- files/en-us/web/api/idbobjectstore/indexnames/index.md | 7 +------ files/en-us/web/api/idbobjectstore/keypath/index.md | 7 +------ files/en-us/web/api/idbobjectstore/name/index.md | 8 +------- files/en-us/web/api/idbobjectstore/put/index.md | 10 +--------- .../en-us/web/api/idbobjectstore/transaction/index.md | 7 +------ .../web/api/idbopendbrequest/blocked_event/index.md | 2 ++ files/en-us/web/api/idbopendbrequest/index.md | 3 +-- .../api/idbopendbrequest/upgradeneeded_event/index.md | 2 +- files/en-us/web/api/idbrequest/error/index.md | 8 +------- files/en-us/web/api/idbrequest/error_event/index.md | 2 +- files/en-us/web/api/idbrequest/index.md | 3 +-- files/en-us/web/api/idbrequest/readystate/index.md | 10 +--------- files/en-us/web/api/idbrequest/result/index.md | 3 +-- files/en-us/web/api/idbrequest/source/index.md | 8 +------- files/en-us/web/api/idbrequest/success_event/index.md | 2 +- files/en-us/web/api/idbrequest/transaction/index.md | 10 +--------- files/en-us/web/api/idbtransaction/abort/index.md | 7 +------ .../en-us/web/api/idbtransaction/abort_event/index.md | 2 +- files/en-us/web/api/idbtransaction/commit/index.md | 3 ++- .../web/api/idbtransaction/complete_event/index.md | 2 ++ files/en-us/web/api/idbtransaction/db/index.md | 7 +------ files/en-us/web/api/idbtransaction/error/index.md | 8 +------- .../en-us/web/api/idbtransaction/error_event/index.md | 2 +- files/en-us/web/api/idbtransaction/index.md | 3 +-- files/en-us/web/api/idbtransaction/mode/index.md | 7 +------ .../en-us/web/api/idbtransaction/objectstore/index.md | 6 +----- files/en-us/web/api/idbversionchangeevent/index.md | 3 +-- .../web/api/idbversionchangeevent/newversion/index.md | 5 +---- .../checking_when_a_deadline_is_due/index.md | 2 +- files/en-us/web/api/notification/icon/index.md | 4 +--- .../using_the_notifications_api/index.md | 2 +- files/en-us/web/api/window/indexeddb/index.md | 4 +--- .../en-us/web/api/workerglobalscope/indexeddb/index.md | 4 +--- 52 files changed, 58 insertions(+), 192 deletions(-) diff --git a/files/en-us/web/api/idbdatabase/close/index.md b/files/en-us/web/api/idbdatabase/close/index.md index 4eb365e045d1cb6..819175e5f6bc1ca 100644 --- a/files/en-us/web/api/idbdatabase/close/index.md +++ b/files/en-us/web/api/idbdatabase/close/index.md @@ -32,6 +32,8 @@ None ({{jsxref("undefined")}}). ## Examples +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). + ```js // Let us open our database const DBOpenRequest = window.indexedDB.open("toDoList", 4); // opening a database. @@ -70,4 +72,3 @@ DBOpenRequest.onsuccess = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbdatabase/close_event/index.md b/files/en-us/web/api/idbdatabase/close_event/index.md index 4cf4f8a68f90908..0e3cd72a8013ab0 100644 --- a/files/en-us/web/api/idbdatabase/close_event/index.md +++ b/files/en-us/web/api/idbdatabase/close_event/index.md @@ -28,7 +28,7 @@ A generic {{domxref("Event")}}. ## Examples -This example opens a database and listens for the `close` event: +This example opens a database and listens for the `close` event. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Open the database diff --git a/files/en-us/web/api/idbdatabase/createobjectstore/index.md b/files/en-us/web/api/idbdatabase/createobjectstore/index.md index c9efff6eedf41d1..c1ea221e2c3767d 100644 --- a/files/en-us/web/api/idbdatabase/createobjectstore/index.md +++ b/files/en-us/web/api/idbdatabase/createobjectstore/index.md @@ -70,6 +70,8 @@ one of the following types: ## Examples +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). + ```js // Let us open our database const request = window.indexedDB.open("toDoList", 4); @@ -124,4 +126,3 @@ request.onupgradeneeded = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbdatabase/index.md b/files/en-us/web/api/idbdatabase/index.md index d6b1a0cd87f93c6..22eb6a26aa72954 100644 --- a/files/en-us/web/api/idbdatabase/index.md +++ b/files/en-us/web/api/idbdatabase/index.md @@ -150,4 +150,3 @@ const objectStore = db - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbdatabase/name/index.md b/files/en-us/web/api/idbdatabase/name/index.md index 4beed9bc7f8b893..d67698f948dfe4d 100644 --- a/files/en-us/web/api/idbdatabase/name/index.md +++ b/files/en-us/web/api/idbdatabase/name/index.md @@ -18,11 +18,7 @@ A string containing the name of the connected database. ## Examples -This example shows a database connection being opened, the resulting -{{domxref("IDBDatabase")}} object being stored in a db variable, and the name property -then being logged. For a full example, see our -[To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) -app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +This example shows a database connection being opened, the resulting {{domxref("IDBDatabase")}} object being stored in a db variable, and the name property then being logged. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -63,4 +59,3 @@ DBOpenRequest.onsuccess = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbdatabase/objectstorenames/index.md b/files/en-us/web/api/idbdatabase/objectstorenames/index.md index da6c2f1c6f032f4..84f8d431241c470 100644 --- a/files/en-us/web/api/idbdatabase/objectstorenames/index.md +++ b/files/en-us/web/api/idbdatabase/objectstorenames/index.md @@ -20,6 +20,8 @@ in the connected database. ## Examples +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). + ```js // Let us open our database const DBOpenRequest = window.indexedDB.open("toDoList", 4); @@ -59,4 +61,3 @@ DBOpenRequest.onsuccess = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbdatabase/transaction/index.md b/files/en-us/web/api/idbdatabase/transaction/index.md index 00ce3c7599df8a2..9946ac9b6f1fd56 100644 --- a/files/en-us/web/api/idbdatabase/transaction/index.md +++ b/files/en-us/web/api/idbdatabase/transaction/index.md @@ -82,7 +82,7 @@ An {{domxref("IDBTransaction")}} object. ## Examples In this example we open a database connection, then use transaction() to open a transaction on the database. -For a complete example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js let db; @@ -139,4 +139,3 @@ const objectStore = transaction.objectStore("toDoList"); - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbdatabase/version/index.md b/files/en-us/web/api/idbdatabase/version/index.md index f6d9347583a706d..a767ba2d4002d6a 100644 --- a/files/en-us/web/api/idbdatabase/version/index.md +++ b/files/en-us/web/api/idbdatabase/version/index.md @@ -16,6 +16,8 @@ An integer containing the version of the connected database. ## Examples +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). + ```js // Let us open our database const DBOpenRequest = window.indexedDB.open("toDoList", 4); @@ -55,4 +57,3 @@ DBOpenRequest.onsuccess = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbdatabase/versionchange_event/index.md b/files/en-us/web/api/idbdatabase/versionchange_event/index.md index b97b1f69291e19c..75471b86125ce5e 100644 --- a/files/en-us/web/api/idbdatabase/versionchange_event/index.md +++ b/files/en-us/web/api/idbdatabase/versionchange_event/index.md @@ -27,7 +27,7 @@ A generic {{domxref("Event")}}. ## Examples -This example opens a database and, on success, adds a listener to `versionchange`: +This example opens a database and, on success, adds a listener to `versionchange`. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Open the database diff --git a/files/en-us/web/api/idbfactory/index.md b/files/en-us/web/api/idbfactory/index.md index 0b66729ab87b781..0d63d263618698d 100644 --- a/files/en-us/web/api/idbfactory/index.md +++ b/files/en-us/web/api/idbfactory/index.md @@ -22,7 +22,7 @@ The **`IDBFactory`** interface of the [IndexedDB API](/en-US/docs/Web/API/Indexe ## Example -In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open version 4 of our database @@ -57,4 +57,3 @@ DBOpenRequest.onsuccess = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbfactory/open/index.md b/files/en-us/web/api/idbfactory/open/index.md index 7eb5cd2398525d6..453eca8a636cfdc 100644 --- a/files/en-us/web/api/idbfactory/open/index.md +++ b/files/en-us/web/api/idbfactory/open/index.md @@ -50,7 +50,7 @@ const request = window.indexedDB.open("toDoList", 4); ``` In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. -For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.querySelector("ul"); @@ -93,4 +93,3 @@ DBOpenRequest.onsuccess = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/add/index.md b/files/en-us/web/api/idbobjectstore/add/index.md index 63797ead77be7d2..89a8219502d17a2 100644 --- a/files/en-us/web/api/idbobjectstore/add/index.md +++ b/files/en-us/web/api/idbobjectstore/add/index.md @@ -68,10 +68,7 @@ one of the following types: ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store using `add()`. Note also the functions attached -to transaction event handlers to report on the outcome of the transaction opening in the -event of success or failure. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store using `add()`. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -147,4 +144,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/autoincrement/index.md b/files/en-us/web/api/idbobjectstore/autoincrement/index.md index 00695c216594cdc..acbd68225cef9d4 100644 --- a/files/en-us/web/api/idbobjectstore/autoincrement/index.md +++ b/files/en-us/web/api/idbobjectstore/autoincrement/index.md @@ -25,12 +25,7 @@ A boolean value: ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store using `add()`. After the object store has been -created, we log `objectStore.autoIncrement` to -the console. For a full working example, see -our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store using `add()`. After the object store has been created, we log `objectStore.autoIncrement` to the console. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -107,4 +102,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/clear/index.md b/files/en-us/web/api/idbobjectstore/clear/index.md index 47a62ee95dde6b9..1da67ecfb8b7558 100644 --- a/files/en-us/web/api/idbobjectstore/clear/index.md +++ b/files/en-us/web/api/idbobjectstore/clear/index.md @@ -45,10 +45,7 @@ If the operation is successful, the value of the request's {{domxref("IDBRequest ## Examples -In the following code snippet, we open a read/write transaction on our database and -clear all the current data out of the object store using `clear()`. For a -full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and clear all the current data out of the object store using `clear()`. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -111,4 +108,3 @@ function clearData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/createindex/index.md b/files/en-us/web/api/idbobjectstore/createindex/index.md index 7f241b464771488..139ce242ebc62bc 100644 --- a/files/en-us/web/api/idbobjectstore/createindex/index.md +++ b/files/en-us/web/api/idbobjectstore/createindex/index.md @@ -76,11 +76,7 @@ This method may raise a {{domxref("DOMException")}} of one of the following type ## Examples -In the following example you can see -the {{domxref("IDBOpenDBRequest.upgradeneeded_event", "onupgradeneeded")}} handler being used to update the -database structure if a database with a higher version number is loaded. -`createIndex()` is used to create new indexes on the object store. For a -full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following example you can see the {{domxref("IDBOpenDBRequest.upgradeneeded_event", "onupgradeneeded")}} handler being used to update the database structure if a database with a higher version number is loaded. `createIndex()` is used to create new indexes on the object store. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js let db; @@ -151,4 +147,3 @@ DBOpenRequest.onupgradeneeded = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/delete/index.md b/files/en-us/web/api/idbobjectstore/delete/index.md index 99e56eab4e4ab48..fe291ec74ede7a6 100644 --- a/files/en-us/web/api/idbobjectstore/delete/index.md +++ b/files/en-us/web/api/idbobjectstore/delete/index.md @@ -53,11 +53,7 @@ This method may raise a {{domxref("DOMException")}} of the following types: ## Examples -The following code snippet shows the `deleteItem()` function, -which is part of the To-do Notifications example app. This app stores to-do -list items using IndexedDB. You can -[see the app's complete code on GitHub](https://github.com/mdn/dom-examples/tree/main/to-do-notifications), and -[try out the app live](https://mdn.github.io/dom-examples/to-do-notifications/). +The following code snippet shows the `deleteItem()` function, which is part of the To-do Notifications example app. This app stores to-do list items using IndexedDB. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). The `deleteItem()` function is called when the user clicks the button to delete a to-do list item. The item key is set in the button's @@ -105,4 +101,3 @@ function deleteItem(event) { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/deleteindex/index.md b/files/en-us/web/api/idbobjectstore/deleteindex/index.md index b2399cc32338996..db35478adee46b4 100644 --- a/files/en-us/web/api/idbobjectstore/deleteindex/index.md +++ b/files/en-us/web/api/idbobjectstore/deleteindex/index.md @@ -42,13 +42,7 @@ None ({{jsxref("undefined")}}). ## Examples -In the following example you can see -the {{domxref("IDBOpenDBRequest.upgradeneeded_event", "onupgradeneeded")}} handler being used to update the -database structure if a database with a higher version number is loaded. -{{domxref("IDBObjectStore.createIndex")}} is used to create new indexes on the object -store, after which we delete the unneeded old indexes with `deleteIndex()`. -For a full working example, see our -[To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following example you can see the {{domxref("IDBOpenDBRequest.upgradeneeded_event", "onupgradeneeded")}} handler being used to update the database structure if a database with a higher version number is loaded. {{domxref("IDBObjectStore.createIndex")}} is used to create new indexes on the object store, after which we delete the unneeded old indexes with `deleteIndex()`. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js let db; @@ -120,4 +114,3 @@ DBOpenRequest.onupgradeneeded = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/get/index.md b/files/en-us/web/api/idbobjectstore/get/index.md index 728671e205fa3e7..03fde2ab1df2e76 100644 --- a/files/en-us/web/api/idbobjectstore/get/index.md +++ b/files/en-us/web/api/idbobjectstore/get/index.md @@ -51,12 +51,7 @@ This method may raise a {{domxref("DOMException")}} of one of the following type ## Examples -In the following code snippet, we open a read/write transaction on our database and get -one specific record from object store using `get()` — a sample record with -the key "Walk dog". Once this data object is retrieved, you could then update it using -normal JavaScript, then put it back into the database using a -{{domxref("IDBObjectStore.put", "put()")}} operation. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and get one specific record from object store using `get()` — a sample record with the key "Walk dog". Once this data object is retrieved, you could then update it using normal JavaScript, then put it back into the database using a {{domxref("IDBObjectStore.put", "put()")}} operation. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -121,4 +116,3 @@ function getData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/index.md b/files/en-us/web/api/idbobjectstore/index.md index ddb09f5ccd0f6ea..1b27d6895f4100e 100644 --- a/files/en-us/web/api/idbobjectstore/index.md +++ b/files/en-us/web/api/idbobjectstore/index.md @@ -57,7 +57,7 @@ The **`IDBObjectStore`** interface of the [IndexedDB API](/en-US/docs/Web/API/In ## Example -This example shows a variety of different uses of object stores, from updating the data structure with {{domxref("IDBObjectStore.createIndex")}} inside an `onupgradeneeded` function, to adding a new item to our object store with {{domxref("IDBObjectStore.add")}}. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +This example shows a variety of different uses of object stores, from updating the data structure with {{domxref("IDBObjectStore.createIndex")}} inside an `onupgradeneeded` function, to adding a new item to our object store with {{domxref("IDBObjectStore.add")}}. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -156,4 +156,3 @@ objectStoreRequest.onsuccess = (event) => { - Using transactions: {{domxref("IDBTransaction")}} - Setting a range of keys: {{domxref("IDBKeyRange")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/indexnames/index.md b/files/en-us/web/api/idbobjectstore/indexnames/index.md index e41311a1088496a..6701b38c60527d7 100644 --- a/files/en-us/web/api/idbobjectstore/indexnames/index.md +++ b/files/en-us/web/api/idbobjectstore/indexnames/index.md @@ -18,11 +18,7 @@ A {{domxref("DOMStringList")}}. ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store using `add()`. After the object store has been -created, we log `objectStore.indexNames` to the console. For a full working example, see -our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store using `add()`. After the object store has been created, we log `objectStore.indexNames` to the console. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -99,4 +95,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/keypath/index.md b/files/en-us/web/api/idbobjectstore/keypath/index.md index c3eafcdd3462085..2f1a3343a0099be 100644 --- a/files/en-us/web/api/idbobjectstore/keypath/index.md +++ b/files/en-us/web/api/idbobjectstore/keypath/index.md @@ -20,11 +20,7 @@ Any value type. ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store using `add()`. After the object store has been -created, we log `objectStore.keyPath` to -the console. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store using `add()`. After the object store has been created, we log `objectStore.keyPath` to the console. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -101,4 +97,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/name/index.md b/files/en-us/web/api/idbobjectstore/name/index.md index e1e84bdf792e0af..b6af54f38a0974e 100644 --- a/files/en-us/web/api/idbobjectstore/name/index.md +++ b/files/en-us/web/api/idbobjectstore/name/index.md @@ -32,12 +32,7 @@ store's name. ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store using `add()`. After the object store has been -created, we log `objectStore.name` to -the console. For a full working example, see -our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store using `add()`. After the object store has been created, we log `objectStore.name` to the console. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -114,4 +109,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/put/index.md b/files/en-us/web/api/idbobjectstore/put/index.md index e542625a187d3ef..14a7a0011ed5e4c 100644 --- a/files/en-us/web/api/idbobjectstore/put/index.md +++ b/files/en-us/web/api/idbobjectstore/put/index.md @@ -62,14 +62,7 @@ This method may raise a {{domxref("DOMException")}} of one of the following type ## Examples -The following example requests a given record title; when that request is successful -the `onsuccess` function gets the associated record from the -{{domxref("IDBObjectStore")}} (made available -as `objectStoreTitleRequest.result`), updates -one property of the record, and then puts the updated record back into the object -store in another request with `put()`. For a full working example, see -our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +The following example requests a given record title; when that request is successful the `onsuccess` function gets the associated record from the {{domxref("IDBObjectStore")}} (made available as `objectStoreTitleRequest.result`), updates one property of the record, and then puts the updated record back into the object store in another request with `put()`. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const title = "Walk dog"; @@ -120,4 +113,3 @@ objectStoreTitleRequest.onsuccess = () => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/transaction/index.md b/files/en-us/web/api/idbobjectstore/transaction/index.md index c427b9071edc99f..6731a63efc97393 100644 --- a/files/en-us/web/api/idbobjectstore/transaction/index.md +++ b/files/en-us/web/api/idbobjectstore/transaction/index.md @@ -18,11 +18,7 @@ An {{domxref("IDBTransaction")}} object. ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store using `add()`. After the object store has been -created, we log `objectStore.transaction` to -the console. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store using `add()`. After the object store has been created, we log `objectStore.transaction` to the console. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Let us open our database @@ -99,4 +95,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbopendbrequest/blocked_event/index.md b/files/en-us/web/api/idbopendbrequest/blocked_event/index.md index a92024084fb1909..48a8894668f8ae5 100644 --- a/files/en-us/web/api/idbopendbrequest/blocked_event/index.md +++ b/files/en-us/web/api/idbopendbrequest/blocked_event/index.md @@ -30,6 +30,8 @@ An {{domxref("IDBVersionChangeEvent")}}. Inherits from {{domxref("Event")}}. ## Examples +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). + Using `addEventListener()`: ```js diff --git a/files/en-us/web/api/idbopendbrequest/index.md b/files/en-us/web/api/idbopendbrequest/index.md index 7dec35044029043..6a62a37de301903 100644 --- a/files/en-us/web/api/idbopendbrequest/index.md +++ b/files/en-us/web/api/idbopendbrequest/index.md @@ -34,7 +34,7 @@ Events specific to this interface are: ## Example -In the following example you can see the onupgradeneeded handler being used to update the database structure if a database with a higher version number is loaded. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/).) +In the following example you can see the onupgradeneeded handler being used to update the database structure if a database with a higher version number is loaded. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js let db; @@ -106,4 +106,3 @@ DBOpenRequest.onupgradeneeded = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbopendbrequest/upgradeneeded_event/index.md b/files/en-us/web/api/idbopendbrequest/upgradeneeded_event/index.md index f785fdbfe88d0b3..30d4eceb3a4d18e 100644 --- a/files/en-us/web/api/idbopendbrequest/upgradeneeded_event/index.md +++ b/files/en-us/web/api/idbopendbrequest/upgradeneeded_event/index.md @@ -30,7 +30,7 @@ An {{domxref("IDBVersionChangeEvent")}}. Inherits from {{domxref("Event")}}. ## Examples -This example opens a database and handles the `upgradeneeded` event by making any necessary updates to the object store. +This example opens a database and handles the `upgradeneeded` event by making any necessary updates to the object store. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Open the database diff --git a/files/en-us/web/api/idbrequest/error/index.md b/files/en-us/web/api/idbrequest/error/index.md index 06c596e95f95a5d..cde4cce2d9c995d 100644 --- a/files/en-us/web/api/idbrequest/error/index.md +++ b/files/en-us/web/api/idbrequest/error/index.md @@ -54,12 +54,7 @@ Possible corrective actions for unrecoverable read errors might include notifyin ## Examples -The following example requests a given record title, `onsuccess` gets the -associated record from the {{domxref("IDBObjectStore")}} (made available as -`objectStoreTitleRequest.result`), updates one property of the record, and then puts the -updated record back into the object store. Also included at the bottom is an -`onerror` function that reports what the error was if the request fails. -For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +The following example requests a given record title, `onsuccess` gets the associated record from the {{domxref("IDBObjectStore")}} (made available as `objectStoreTitleRequest.result`), updates one property of the record, and then puts the updated record back into the object store. Also included at the bottom is an `onerror` function that reports what the error was if the request fails. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const title = "Walk dog"; @@ -115,4 +110,3 @@ objectStoreTitleRequest.onerror = () => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbrequest/error_event/index.md b/files/en-us/web/api/idbrequest/error_event/index.md index 2d608822c211e18..d4688755eb72f3f 100644 --- a/files/en-us/web/api/idbrequest/error_event/index.md +++ b/files/en-us/web/api/idbrequest/error_event/index.md @@ -26,7 +26,7 @@ A generic {{domxref("Event")}}. ## Examples -This example opens a database and tries to add a record, listening for the `error` event for the `add()` operation (this will occur if, for example, a record with the given `taskTitle` already exists): +This example opens a database and tries to add a record, listening for the `error` event for the `add()` operation (this will occur if, for example, a record with the given `taskTitle` already exists). For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Open the database diff --git a/files/en-us/web/api/idbrequest/index.md b/files/en-us/web/api/idbrequest/index.md index 7ac11f3c9dcd643..732fb31f63d2d96 100644 --- a/files/en-us/web/api/idbrequest/index.md +++ b/files/en-us/web/api/idbrequest/index.md @@ -57,7 +57,7 @@ The interface {{domxref("IDBOpenDBRequest")}} is derived from `IDBRequest`. ### Basic usage In the following code snippet, we open a database asynchronously and make a request; event listeners for `error` and `success` are included to handle the success and error cases. -For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/).) +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js let db; @@ -97,4 +97,3 @@ DBOpenRequest.addEventListener("success", (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbrequest/readystate/index.md b/files/en-us/web/api/idbrequest/readystate/index.md index 3db287bf43e4a2c..c6e3a4c7ecefaaa 100644 --- a/files/en-us/web/api/idbrequest/readystate/index.md +++ b/files/en-us/web/api/idbrequest/readystate/index.md @@ -26,14 +26,7 @@ One of the following strings: ## Examples -The following example requests a given record title, `onsuccess` gets the -associated record from the {{domxref("IDBObjectStore")}} (made available -as `objectStoreTitleRequest.result`), updates -one property of the record, and then puts the updated record back into the object -store in another request. The `readyState` of the 2nd request is logged to -the developer console. For a full working example, see our -[To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +The following example requests a given record title, `onsuccess` gets the associated record from the {{domxref("IDBObjectStore")}} (made available as `objectStoreTitleRequest.result`), updates one property of the record, and then puts the updated record back into the object store in another request. The `readyState` of the 2nd request is logged to the developer console. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const title = "Walk dog"; @@ -86,4 +79,3 @@ objectStoreTitleRequest.onsuccess = () => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbrequest/result/index.md b/files/en-us/web/api/idbrequest/result/index.md index a59cb6166763a2b..101806e5be3d379 100644 --- a/files/en-us/web/api/idbrequest/result/index.md +++ b/files/en-us/web/api/idbrequest/result/index.md @@ -27,7 +27,7 @@ any. ### Basic usage The following example requests a given record title. On success, the associated record is retrieved from the {{domxref("IDBObjectStore")}} (made available as `objectStoreTitleRequest.result`), one property of the record is updated, and then the updated record is put back into the object store. -For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const title = "Walk dog"; @@ -75,4 +75,3 @@ objectStoreTitleRequest.addEventListener("success", () => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbrequest/source/index.md b/files/en-us/web/api/idbrequest/source/index.md index c040b95ce3fc89f..9749346933f1150 100644 --- a/files/en-us/web/api/idbrequest/source/index.md +++ b/files/en-us/web/api/idbrequest/source/index.md @@ -20,12 +20,7 @@ An object representing the source of the request, such as an {{domxref("IDBIndex ## Examples -The following example requests a given record title, `onsuccess` gets the -associated record from the {{domxref("IDBObjectStore")}} (made available -as `objectStoreTitleRequest.result`), updates -one property of the record, and then puts the updated record back into the object -store in another request. The source of the 2nd request is logged to the developer -console. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +The following example requests a given record title, `onsuccess` gets the associated record from the {{domxref("IDBObjectStore")}} (made available as `objectStoreTitleRequest.result`), updates one property of the record, and then puts the updated record back into the object store in another request. The source of the 2nd request is logged to the developer console. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const title = "Walk dog"; @@ -75,4 +70,3 @@ objectStoreTitleRequest.onsuccess = () => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbrequest/success_event/index.md b/files/en-us/web/api/idbrequest/success_event/index.md index d548ddec3062cee..9d5f2c184e0f7b8 100644 --- a/files/en-us/web/api/idbrequest/success_event/index.md +++ b/files/en-us/web/api/idbrequest/success_event/index.md @@ -28,7 +28,7 @@ A generic {{domxref("Event")}}. ## Examples -This example tries to open a database and listens for the `success` event using `addEventListener()`: +This example tries to open a database and listens for the `success` event using `addEventListener()`. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Open the database diff --git a/files/en-us/web/api/idbrequest/transaction/index.md b/files/en-us/web/api/idbrequest/transaction/index.md index 6a2c2ec173e4267..82d700f97659e3f 100644 --- a/files/en-us/web/api/idbrequest/transaction/index.md +++ b/files/en-us/web/api/idbrequest/transaction/index.md @@ -29,14 +29,7 @@ An {{domxref("IDBTransaction")}}. ## Examples -The following example requests a given record title, `onsuccess` gets the -associated record from the {{domxref("IDBObjectStore")}} (made available -as `objectStoreTitleRequest.result`), updates -one property of the record, and then puts the updated record back into the object -store in another request. The source of the requests is logged to the developer -console — both originate from the same transaction. For a full working example, see -our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app -([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +The following example requests a given record title, `onsuccess` gets the associated record from the {{domxref("IDBObjectStore")}} (made available as `objectStoreTitleRequest.result`), updates one property of the record, and then puts the updated record back into the object store in another request. The source of the requests is logged to the developer console — both originate from the same transaction. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const title = "Walk dog"; @@ -115,4 +108,3 @@ openRequest.onsuccess = () => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbtransaction/abort/index.md b/files/en-us/web/api/idbtransaction/abort/index.md index aaad0399689e0e7..243d229d8bcb051 100644 --- a/files/en-us/web/api/idbtransaction/abort/index.md +++ b/files/en-us/web/api/idbtransaction/abort/index.md @@ -36,11 +36,7 @@ None ({{jsxref("undefined")}}). ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store. Note also the functions attached to transaction event -handlers to report on the outcome of the transaction opening in the event of success or -failure. At the end, we abort any activity done under the current transaction using -`abort()`. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([View example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. At the end, we abort any activity done under the current transaction using `abort()`. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.getElementById("notifications"); @@ -124,4 +120,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbtransaction/abort_event/index.md b/files/en-us/web/api/idbtransaction/abort_event/index.md index b9281b116f5e989..6952495e91d14e0 100644 --- a/files/en-us/web/api/idbtransaction/abort_event/index.md +++ b/files/en-us/web/api/idbtransaction/abort_event/index.md @@ -42,7 +42,7 @@ For more information, see [Event bubbling](/en-US/docs/Learn_web_development/Cor ## Examples -This example opens a database (creating the database if it does not exist), then opens a transaction, adds a listener to the `abort` event, then aborts the transaction to trigger the event. +This example opens a database (creating the database if it does not exist), then opens a transaction, adds a listener to the `abort` event, then aborts the transaction to trigger the event. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Open the database diff --git a/files/en-us/web/api/idbtransaction/commit/index.md b/files/en-us/web/api/idbtransaction/commit/index.md index c8288cb448d205b..3e806f9903c1158 100644 --- a/files/en-us/web/api/idbtransaction/commit/index.md +++ b/files/en-us/web/api/idbtransaction/commit/index.md @@ -35,6 +35,8 @@ None ({{jsxref("undefined")}}). ## Examples +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). + ```js const note = document.getElementById("notifications"); @@ -85,4 +87,3 @@ transaction.commit(); - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbtransaction/complete_event/index.md b/files/en-us/web/api/idbtransaction/complete_event/index.md index acd547cc422f127..74a6073a09e247a 100644 --- a/files/en-us/web/api/idbtransaction/complete_event/index.md +++ b/files/en-us/web/api/idbtransaction/complete_event/index.md @@ -26,6 +26,8 @@ A generic {{domxref("Event")}}. ## Examples +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). + Using {{DOMxRef("EventTarget.addEventListener", "addEventListener()")}}: ```js diff --git a/files/en-us/web/api/idbtransaction/db/index.md b/files/en-us/web/api/idbtransaction/db/index.md index 9719cedc7a12039..9e56d8b9e094b7c 100644 --- a/files/en-us/web/api/idbtransaction/db/index.md +++ b/files/en-us/web/api/idbtransaction/db/index.md @@ -17,11 +17,7 @@ An {{domxref("IDBDatabase")}} object. ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store. Note also the functions attached to transaction event -handlers to report on the outcome of the transaction opening in the event of success or -failure. At the end, we return the associated database connection using `db`. -For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. At the end, we return the associated database connection using `db`. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.getElementById("notifications"); @@ -106,4 +102,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbtransaction/error/index.md b/files/en-us/web/api/idbtransaction/error/index.md index 2e647ec7a5b5576..89bd12a6100f27b 100644 --- a/files/en-us/web/api/idbtransaction/error/index.md +++ b/files/en-us/web/api/idbtransaction/error/index.md @@ -22,12 +22,7 @@ was successfully committed. ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store. Note also the functions attached to transaction event -handlers to report on the outcome of the transaction opening in the event of success or -failure. Note the `transaction.onerror = (event) => { };` block, making -use of `transaction.error` to help in reporting what went wrong when the -transaction was unsuccessful. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([View example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. Note the `transaction.onerror = (event) => { };` block, making use of `transaction.error` to help in reporting what went wrong when the transaction was unsuccessful. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.getElementById("notifications"); @@ -109,4 +104,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbtransaction/error_event/index.md b/files/en-us/web/api/idbtransaction/error_event/index.md index d184ba7f5cb9f2e..189353b46ce0693 100644 --- a/files/en-us/web/api/idbtransaction/error_event/index.md +++ b/files/en-us/web/api/idbtransaction/error_event/index.md @@ -35,7 +35,7 @@ For more information, see [Event bubbling](/en-US/docs/Learn_web_development/Cor ## Examples -This example opens a database and tries to add a record, listening for the `error` event for the `add()` operation (this will occur if, for example, a record with the given `taskTitle` already exists): +This example opens a database and tries to add a record, listening for the `error` event for the `add()` operation (this will occur if, for example, a record with the given `taskTitle` already exists). For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js // Open the database diff --git a/files/en-us/web/api/idbtransaction/index.md b/files/en-us/web/api/idbtransaction/index.md index 9b0e67ae177a7ac..0325a33c8ef01e8 100644 --- a/files/en-us/web/api/idbtransaction/index.md +++ b/files/en-us/web/api/idbtransaction/index.md @@ -138,7 +138,7 @@ const myIDBTransaction = window.IDBTransaction || ## Examples -In the following code snippet, we open a read/write transaction on our database and add some data to an object store. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.getElementById("notifications"); @@ -219,4 +219,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbtransaction/mode/index.md b/files/en-us/web/api/idbtransaction/mode/index.md index 14cc85027213625..eae6896000b7cd9 100644 --- a/files/en-us/web/api/idbtransaction/mode/index.md +++ b/files/en-us/web/api/idbtransaction/mode/index.md @@ -34,11 +34,7 @@ The following values are available: ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store. Note also the functions attached to transaction event -handlers to report on the outcome of the transaction opening in the event of success or -failure. At the end, we log the mode of the current transaction using `mode`. -For a full working example, see our [To-do Notifications app](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. At the end, we log the mode of the current transaction using `mode`. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.getElementById("notifications"); @@ -123,4 +119,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbtransaction/objectstore/index.md b/files/en-us/web/api/idbtransaction/objectstore/index.md index 1ab83ee6e955be6..eec2447a7e4d228 100644 --- a/files/en-us/web/api/idbtransaction/objectstore/index.md +++ b/files/en-us/web/api/idbtransaction/objectstore/index.md @@ -40,10 +40,7 @@ An {{domxref("IDBObjectStore")}} object for accessing an object store. ## Examples -In the following code snippet, we open a read/write transaction on our database and add -some data to an object store. Note also the functions attached to transaction event -handlers to report on the outcome of the transaction opening in the event of success or -failure. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([View example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we open a read/write transaction on our database and add some data to an object store. Note also the functions attached to transaction event handlers to report on the outcome of the transaction opening in the event of success or failure. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.getElementById("notifications"); @@ -125,4 +122,3 @@ function addData() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbversionchangeevent/index.md b/files/en-us/web/api/idbversionchangeevent/index.md index 622744e1e894491..cd2c8d57d7a02bc 100644 --- a/files/en-us/web/api/idbversionchangeevent/index.md +++ b/files/en-us/web/api/idbversionchangeevent/index.md @@ -31,7 +31,7 @@ _No specific method, but inherits methods from its parent, {{domxref("Event")}} ## Example -In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. Upon a version change (after an `upgradeneeded` event), the `success` event will implement the `IDBVersionChangeEvent` interface. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. Upon a version change (after an `upgradeneeded` event), the `success` event will implement the `IDBVersionChangeEvent` interface. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.querySelector("ul"); @@ -70,4 +70,3 @@ DBOpenRequest.onsuccess = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbversionchangeevent/newversion/index.md b/files/en-us/web/api/idbversionchangeevent/newversion/index.md index a10ccdf5ef76b14..6481705bdedbe48 100644 --- a/files/en-us/web/api/idbversionchangeevent/newversion/index.md +++ b/files/en-us/web/api/idbversionchangeevent/newversion/index.md @@ -18,9 +18,7 @@ A number that is a 64-bit integer or null if the database is being deleted. ## Examples -In the following code snippet, we make a request to open a database, and include -handlers for the success and error cases. These events are fired via the custom -`IDBVersionChangeEvent` interface. For a full working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). +In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. These events are fired via the custom `IDBVersionChangeEvent` interface. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const note = document.querySelector("ul"); @@ -60,4 +58,3 @@ DBOpenRequest.onsuccess = (event) => { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/indexeddb_api/checking_when_a_deadline_is_due/index.md b/files/en-us/web/api/indexeddb_api/checking_when_a_deadline_is_due/index.md index 37803c1a1f0bd46..f9eb7b0bf00a220 100644 --- a/files/en-us/web/api/indexeddb_api/checking_when_a_deadline_is_due/index.md +++ b/files/en-us/web/api/indexeddb_api/checking_when_a_deadline_is_due/index.md @@ -10,7 +10,7 @@ In this article we look at a complex example involving checking the current time ![A screenshot of the sample app. A red main title saying To do app, a test to-do item, and a red form for users to enter new tasks](to-do-app.png) -The main example application we will be referring to in this article is **To-do list notifications**, a simple to-do list application that stores task titles and deadline times and dates via [IndexedDB](/en-US/docs/Web/API/IndexedDB_API), and then provides users with notifications when deadline dates are reached, via the [Notification](/en-US/docs/Web/API/Notification), and [Vibration](/en-US/docs/Web/API/Vibration_API) APIs. You can [download the To-do list notifications app from GitHub](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) and play around with the source code, or [view the app running live](https://mdn.github.io/dom-examples/to-do-notifications/). +The main example application we will be referring to in this article is **To-do list notifications**, a simple to-do list application that stores task titles and deadline times and dates via [IndexedDB](/en-US/docs/Web/API/IndexedDB_API), and then provides users with notifications when deadline dates are reached, via the [Notification](/en-US/docs/Web/API/Notification), and [Vibration](/en-US/docs/Web/API/Vibration_API) APIs. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ## The basic problem diff --git a/files/en-us/web/api/notification/icon/index.md b/files/en-us/web/api/notification/icon/index.md index 3481b3cb1d0a557..c70b9ec46e8b554 100644 --- a/files/en-us/web/api/notification/icon/index.md +++ b/files/en-us/web/api/notification/icon/index.md @@ -19,9 +19,7 @@ A string. ## Examples -In our [To-do list app](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([view the app running live](https://mdn.github.io/dom-examples/to-do-notifications/)), we use the {{domxref("Notification.Notification","Notification()")}} -constructor to fire a notification, passing it arguments to specify the body, icon and -title we want. +In our To-do Notifications app, we use the {{domxref("Notification.Notification","Notification()")}} constructor to fire a notification, passing it arguments to specify the body, icon and title we want. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js const notification = new Notification("To do list", { diff --git a/files/en-us/web/api/notifications_api/using_the_notifications_api/index.md b/files/en-us/web/api/notifications_api/using_the_notifications_api/index.md index c13a752f2276a73..ba148d1bf7fcf06 100644 --- a/files/en-us/web/api/notifications_api/using_the_notifications_api/index.md +++ b/files/en-us/web/api/notifications_api/using_the_notifications_api/index.md @@ -22,7 +22,7 @@ Many examples of this now exist, such as [Slack](https://slack.com/). We've written a real-world example — a to-do list app — to give more of an idea of how web notifications can be used. It stores data locally using [IndexedDB](/en-US/docs/Web/API/IndexedDB_API) and notifies users when tasks are due using system notifications. -[Download the To-do list code](https://github.com/mdn/dom-examples/tree/main/to-do-notifications), or [view the app running live](https://mdn.github.io/dom-examples/to-do-notifications/). +For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ## Requesting permission diff --git a/files/en-us/web/api/window/indexeddb/index.md b/files/en-us/web/api/window/indexeddb/index.md index 8dc8ee84fe72102..2ea02a508aa110b 100644 --- a/files/en-us/web/api/window/indexeddb/index.md +++ b/files/en-us/web/api/window/indexeddb/index.md @@ -17,8 +17,7 @@ An {{domxref("IDBFactory")}} object. ## Examples -The following code creates a request for a database to be opened asynchronously, after -which the database is opened when the request's `onsuccess` handler is fired: +The following code creates a request for a database to be opened asynchronously, after which the database is opened when the request's `onsuccess` handler is fired. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js let db; @@ -46,4 +45,3 @@ function openDB() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/workerglobalscope/indexeddb/index.md b/files/en-us/web/api/workerglobalscope/indexeddb/index.md index e563f7cc2588aed..8e9984f77d2cd25 100644 --- a/files/en-us/web/api/workerglobalscope/indexeddb/index.md +++ b/files/en-us/web/api/workerglobalscope/indexeddb/index.md @@ -17,8 +17,7 @@ An {{domxref("IDBFactory")}} object. ## Examples -The following code creates a request for a database to be opened asynchronously, after -which the database is opened when the request's `onsuccess` handler is fired: +The following code creates a request for a database to be opened asynchronously, after which the database is opened when the request's `onsuccess` handler is fired. For a complete working example, see our [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) app ([view example live](https://mdn.github.io/dom-examples/to-do-notifications/)). ```js let db; @@ -46,4 +45,3 @@ function openDB() { - Setting a range of keys: {{domxref("IDBKeyRange")}} - Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} - Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)).