Changes

Jump to navigation Jump to search
m
no edit summary
Line 232: Line 232:     
function recordAdd(pddbname, record){
 
function recordAdd(pddbname, record){
 +
  console.log("Add " + pddbname + '@' + record.user.name);
 
   var pddb = window.indexedDB.open(pddbname, 3);
 
   var pddb = window.indexedDB.open(pddbname, 3);
 
   pddb.onupgradeneeded = function() {
 
   pddb.onupgradeneeded = function() {
 
     var db = pddb.result;
 
     var db = pddb.result;
     var store = db.createObjectStore(PersonalDataDataBaseName, {keyPath: "id"});
+
     var store = db.createObjectStore(pddbname, {keyPath: "id"});
    
// shouldn't the index be the wiki.personaldata.io username?  
 
// shouldn't the index be the wiki.personaldata.io username?  
Line 243: Line 244:  
   pddb.onsuccess = function() {
 
   pddb.onsuccess = function() {
 
     var db = pddb.result;
 
     var db = pddb.result;
     var tx = db.transaction(PersonalDataDataBaseName, "readwrite");
+
     var tx = db.transaction(pddbname, "readwrite");
     var store = tx.objectStore(PersonalDataDataBaseName);
+
     var store = tx.objectStore(pddbname);
 
     var index = store.index("NameIndex");   
 
     var index = store.index("NameIndex");   
   Line 284: Line 285:  
// Otherwise all other fields of the record object are disregarded
 
// Otherwise all other fields of the record object are disregarded
 
function recordUpdate( pddbname, record, field, value ) {
 
function recordUpdate( pddbname, record, field, value ) {
 
+
  console.log("Add " + pddbname + '@' + record.user.name + ":" + field + '/w:' + value);
 
   var pddb = window.indexedDB.open(pddbname, 3);
 
   var pddb = window.indexedDB.open(pddbname, 3);
 
   pddb.onupgradeneeded = function() {
 
   pddb.onupgradeneeded = function() {
 
     var db = pddb.result;
 
     var db = pddb.result;
     var store = db.createObjectStore(PersonalDataDataBaseName, {keyPath: "id"});
+
     var store = db.createObjectStore(pddbname, {keyPath: "id"});
 
     var index = store.createIndex("NameIndex", ["name.user"]);
 
     var index = store.createIndex("NameIndex", ["name.user"]);
 
   };
 
   };
Line 294: Line 295:  
         // Start a new transaction
 
         // Start a new transaction
 
         var db = pddb.result;
 
         var db = pddb.result;
         var tx = db.transaction(PersonalDataDataBaseName, "readwrite");
+
         var tx = db.transaction(pddbname, "readwrite");
         var store = tx.objectStore(PersonalDataDataBaseName);
+
         var store = tx.objectStore(pddbname);
 
         var index = store.index("NameIndex");
 
         var index = store.index("NameIndex");
   Line 319: Line 320:     
         // perform a sanity check if the update was successful, could be used to initiate a retry upon false
 
         // perform a sanity check if the update was successful, could be used to initiate a retry upon false
         getRecordAgain = index.get([record.name.user]);
+
         getRecordAgain = index.get([inp_obj.name.user]);
 
         getRecordAgain.onsuccess = function() {
 
         getRecordAgain.onsuccess = function() {
 
             console.log(getRecordAgain);  // => "Bob"
 
             console.log(getRecordAgain);  // => "Bob"
Line 342: Line 343:  
   pddb.onupgradeneeded = function() {
 
   pddb.onupgradeneeded = function() {
 
     var db = pddb.result;
 
     var db = pddb.result;
     var store = db.createObjectStore(PersonalDataDataBaseName, {keyPath: "id"});
+
     var store = db.createObjectStore(pddbname, {keyPath: "id"});
 
     var index = store.createIndex("NameIndex", ["name.user"]);
 
     var index = store.createIndex("NameIndex", ["name.user"]);
 
   };
 
   };
 
   pddb.onsuccess = function() {
 
   pddb.onsuccess = function() {
 
     var db = pddb.result;
 
     var db = pddb.result;
     var tx = db.transaction(PersonalDataDataBaseName, "readwrite");
+
     var tx = db.transaction(pddbname, "readwrite");
     var store = tx.objectStore(PersonalDataDataBaseName);
+
     var store = tx.objectStore(pddbname);
 
     var index = store.index("NameIndex");   
 
     var index = store.index("NameIndex");   
   Line 375: Line 376:  
   pddb.onupgradeneeded = function() {
 
   pddb.onupgradeneeded = function() {
 
     var db = pddb.result;
 
     var db = pddb.result;
     var store = db.createObjectStore(PersonalDataDataBaseName, {keyPath: "id"});
+
     var store = db.createObjectStore(pddbname, {keyPath: "id"});
 
     var index = store.createIndex("NameIndex", ["name.user"]);
 
     var index = store.createIndex("NameIndex", ["name.user"]);
 
   };
 
   };
 
   pddb.onsuccess = function() {
 
   pddb.onsuccess = function() {
 
     var db = pddb.result;
 
     var db = pddb.result;
     var tx = db.transaction(PersonalDataDataBaseName, "readwrite");
+
     var tx = db.transaction(pddbname, "readwrite");
     var store = tx.objectStore(PersonalDataDataBaseName);
+
     var store = tx.objectStore(pddbname);
 
     var index = store.index("NameIndex");   
 
     var index = store.index("NameIndex");   
   Line 398: Line 399:  
         store.put(inp_obj);
 
         store.put(inp_obj);
 
     }
 
     }
 +
      getRecordAgain = index.get([inp_obj.name.user]);
 +
      getRecordAgain.onsuccess = function() {
 +
        console.log(getRecordAgain);  // => "Bob"
 +
        if ( getRecordAgain.result[field] == value ) {
 +
          console.log("Delete succeeded");
 +
        } else {
 +
          console.log("Delete unsuccessful");
 +
        }
 +
      };
    
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
530

edits

Navigation menu