RETRIEVE OBJECTS USING THE INDEXEDDB API

You can retrieve objects out of an IndexedDB object store using a cursor. This is an enumeration tool that progresses through the list of all objects and returns them to your JavaScript program one by one:

function displayObjects() {
   var transaction =
 db.transaction(objectStore, IDBTransaction.
 READ_ONLY);
  var store = transaction.
 objectStore(objectStore);
  var request = store.openCursor();
   request.onsuccess = function(event) {
     if (cursor = event.target.result) {
       renderObject(cursor.value);
      cursor.continue();
     }
   };
 }

The store.openCursor() method starts the object store retrieval process. For each object, a success event fires. You must retrieve the cursor from event.target. result, process the cursor’s ...

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.