February 2018
Intermediate to advanced
298 pages
8h 22m
English
Whenever a connection is established, the onsuccess event is fired. Only read-write operations in the onupgradeneeded work because it won't be fired if the version number of the database is not increased.
As a matter of fact, we recommend changing the database schema from the onupgradeneeded event. When you're in onsuccess, perform only the CRUD operations (which are Create, Update, Retrieve, and Delete).
We can do our operations inside the success event with the following code:
const open = window.indexedDB.open("types", 1); // same database as aboveopen.onsuccess = () => { const dbHandler = open.result; const transaction = dbHandler.transaction(['frontend'], 'readonly'); const storeHandler = transaction.objectStore('frontend'); ...Read now
Unlock full access