const note = document.querySelector("ul");
// Let us open version 4 of our database
const DBOpenRequest = window.indexedDB.open("toDoList", 4);
// these two event handlers act on the database being opened
DBOpenRequest.onerror = (event) => {
note.appendChild(document.createElement("li")).textContent =
"Error loading database.";
};
DBOpenRequest.onsuccess = (event) => {
note.appendChild(document.createElement("li")).textContent =
"Database initialized.";
// store the result of opening the database in the db variable.
// This is used a lot later on, for opening transactions and suchlike.
const db = DBOpenRequest.result;
};IDBVersionChangeEvent: newVersion property / notebook
IDBVersionChangeEvent: newVersion property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.