| Line 279: |
Line 279: |
| | // shouldn't the index be the wiki.personaldata.io username? | | // shouldn't the index be the wiki.personaldata.io username? |
| | | | |
| − | var index = store.createIndex("NameIndex", ["name.user"]); | + | var index = store.createIndex("NameIndex", ["id"]); |
| | }; | | }; |
| | pddb.onsuccess = function() { | | pddb.onsuccess = function() { |
| Line 290: |
Line 290: |
| | | | |
| | // Get the original record from the db... | | // Get the original record from the db... |
| − | var getRecord = index.get([record.name.user]); | + | var getRecord = index.get([record.id]); |
| | getRecord.onsuccess = function() { | | getRecord.onsuccess = function() { |
| | /* | | /* |
| Line 308: |
Line 308: |
| | //} | | //} |
| | | | |
| − | var sanitycheck = index.get([inp_obj.name.user]); | + | var sanitycheck = index.get([inp_obj.id]); |
| | sanitycheck.onsuccess = function() { | | sanitycheck.onsuccess = function() { |
| | console.log(sanitycheck); | | console.log(sanitycheck); |
| Line 328: |
Line 328: |
| | // 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, cellnumber, value ) { | | function recordUpdate( pddbname, record, field, cellnumber, value ) { |
| − | console.log("Add " + pddbname + '@' + record.name.user + ":" + field + '/w:' + value); | + | console.log("Add " + pddbname + '@' + record.id + ":" + 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(pddbname, {keyPath: "id"}); | | var store = db.createObjectStore(pddbname, {keyPath: "id"}); |
| − | var index = store.createIndex("NameIndex", ["name.user"]); | + | var index = store.createIndex("NameIndex", ["id"]); |
| | }; | | }; |
| | pddb.onsuccess = function() { | | pddb.onsuccess = function() { |
| Line 345: |
Line 345: |
| | | | |
| | var inp_obj; | | var inp_obj; |
| − | var getRecord = index.get([record.name.user]); | + | var getRecord = index.get([record.id]); |
| | // let's try to get the record to be updated from the store | | // let's try to get the record to be updated from the store |
| | getRecord.onsuccess = function() { | | getRecord.onsuccess = function() { |
| Line 363: |
Line 363: |
| | | | |
| | // 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([inp_obj.name.user]); | + | getRecordAgain = index.get([inp_obj.id]); |
| | getRecordAgain.onsuccess = function() { | | getRecordAgain.onsuccess = function() { |
| | console.log(getRecordAgain); // => "Bob" | | console.log(getRecordAgain); // => "Bob" |
| Line 387: |
Line 387: |
| | var db = pddb.result; | | var db = pddb.result; |
| | var store = db.createObjectStore(pddbname, {keyPath: "id"}); | | var store = db.createObjectStore(pddbname, {keyPath: "id"}); |
| − | var index = store.createIndex("NameIndex", ["name.user"]); | + | var index = store.createIndex("NameIndex", ["id"]); |
| | }; | | }; |
| | pddb.onsuccess = function() { | | pddb.onsuccess = function() { |
| Line 397: |
Line 397: |
| | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||[ Essential recordCheck ]|||||||||||||| | | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||[ Essential recordCheck ]|||||||||||||| |
| | | | |
| − | var recordcheck = index.get([record.name.user]); | + | var recordcheck = index.get([record.id]); |
| | recordcheck.onsuccess = function() { | | recordcheck.onsuccess = function() { |
| | if ( recordcheck.result != undefined ) { | | if ( recordcheck.result != undefined ) { |
| Line 421: |
Line 421: |
| | var db = pddb.result; | | var db = pddb.result; |
| | var store = db.createObjectStore(pddbname, {keyPath: "id"}); | | var store = db.createObjectStore(pddbname, {keyPath: "id"}); |
| − | var index = store.createIndex("NameIndex", ["name.user"]); | + | var index = store.createIndex("NameIndex", ["id"]); |
| | }; | | }; |
| | pddb.onsuccess = function() { | | pddb.onsuccess = function() { |
| Line 432: |
Line 432: |
| | | | |
| | var inp_obj; | | var inp_obj; |
| − | var recordcheck = index.get([record.name.user]); | + | var recordcheck = index.get([record.id]); |
| | recordcheck.onsuccess = function() { | | recordcheck.onsuccess = function() { |
| | if ( recordcheck.result != undefined ) { | | if ( recordcheck.result != undefined ) { |
| Line 443: |
Line 443: |
| | store.put( inp_obj ); | | store.put( inp_obj ); |
| | | | |
| − | getRecordAgain = index.get([inp_obj.name.user]); | + | getRecordAgain = index.get([inp_obj.id]); |
| | getRecordAgain.onsuccess = function() { | | getRecordAgain.onsuccess = function() { |
| | console.log(getRecordAgain); // => "Bob" | | console.log(getRecordAgain); // => "Bob" |