title: How to retrieve the data from database using Indexed DB
body: <p>I have an existed database. I'm trying to retrieve the data from database using indexedDB but i'm unable to get the data from database.</p>
  
  <pre><code> var data = [];
      // creating or opening the database
      var db;
      var request = window.indexedDB.open("database");
  
      request.onerror = function(event) {
        console.log("error: ");
      };
  
      request.onsuccess = function(event) {
        db = request.result;
        console.log("success: "+ db);
      };
  
      request.onupgradeneeded = function(event) {
           var db = event.target.result;
           var objectStore = db.createObjectStore("Subject", {keyPath: "id"});
           for (var i in data) {
                   objectStore.add(data[i]);       
           }
      }
  
  
  function readAll() {
      var objectStore = db.transaction("Subject").objectStore("Subject");
      console.log(objectStore);
      objectStore.openCursor().onsuccess = function(event) {
        var cursor = event.target.result;
        if (cursor) {
              alert("Name for id " + cursor.key + " is " + cursor.value.Subject);
              cursor.continue();
        }
        else {
              alert("No more entries!");
        }
      };      
  }
  </code></pre>
  
  <p>Thanks in Advance.</p>