CREATE A NEW IyNDEXEDDB OBJECT STORE

Before creating a new IndexedDB object store, first attempt to read something from it. This will throw an exception error with the code NOT_FOUND_ERR. This is your cue to create the object store by calling db.setVersion() and db.createObjectStore().

Before you begin, you must set an object store name. This can literally be anything, but remember that the information you save to the IndexedDB API will be under this store name, housed within the database name you picked earlier. Because you will be referring to this store name several times, store it as a global variable alongside var db:

var objectStore ='myStore';

The store exception test must be placed within the openDB. onsuccess function, after db = ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.