SHARE
TWEET

Untitled

a guest Jun 18th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function RetrieveTableRows(db, Table, Callback) {
  2.    var returnData = [];
  3.  
  4.    var trans = db.transaction([Table], "readwrite");
  5.    var store = trans.objectStore(Table);
  6.  
  7.    var keyRange = IDBKeyRange.lowerBound(0);
  8.    var cursorRequest = store.openCursor(keyRange);
  9.  
  10.    cursorRequest.onerror = window.indexedDB.onerror;
  11.  
  12.    cursorRequest.onsuccess = function(e) {
  13.       var result = e.target.result;
  14.       if(!!result == false) {
  15.          // Send the information back to our specified function
  16.          Callback(returnData);
  17.          return
  18.       }
  19.       returnData.push(result.value);
  20.  
  21.       result.continue();
  22.    };    
  23.  
  24. }
  25.  
  26. var request = indexedDB.open('kiotviet');
  27.  
  28. request.onsuccess = function () {
  29.     var db = request.result;
  30.     RetrieveTableRows(db, "Attributes", (data) => {
  31.         console.log(data);
  32.        
  33.         var csv = data.map(item => item.Name);
  34.         console.log(csv);
  35.        
  36.         var csv = data.map(item => item.Name).join(', ');
  37.         console.log(csv);
  38.     });
  39.  
  40. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top