February 2018
Intermediate to advanced
298 pages
8h 22m
English
As discussed previously, we can now handle the upgradeneeded event. As we have just created the database for the first time, the following upgradeneeded event will be fired:
const open = window.indexedDB.open("types", 1);// Let us create a schema for the databaseopen.onupgradeneeded = () => { const dbHandler = open.result; const storeHandler = dbHandler.createObjectStore("frontend");};
Okay, in the preceding code, we got the IDBDatabase object handler, which we call dbHandler, by calling open.result.
Then, we created something called an object store in indexedDB. Object stores are like tables in indexedDB, where the data is stored in the form of key-value pairs.
Read now
Unlock full access