| Line 22: |
Line 22: |
| | }; | | }; |
| | | | |
| | + | |
| | + | var self = mw.user.GetName(); |
| | // Take username for standard databasename format | | // Take username for standard databasename format |
| − | var PersonalDataDataBaseName = "PD.IO" + mw.user.getName() + "Database"; | + | var PersonalDataDataBaseName = "PD.IO" + self + "Database"; |
| − | console.log(PersonalDataDataBaseName);
| |
| | // Use username in user to get up to date version of self | | // Use username in user to get up to date version of self |
| − | var CurrentPerson = {id: 0, name: {user: mw.user.getName(), first: "", last: ""}, age: 0}; | + | var CurrentPerson = {id: 0, name: {user: self, first: "", last: ""}, age: 0}; |
| | + | |
| | + | CurrentPerson = recordUpdate( PersonalDataDataBaseName, CurrentPerson ); |
| | + | |
| | console.log( CurrentPerson ); | | console.log( CurrentPerson ); |
| − | CurrentPerson = recordUpdate( PersonalDataDataBaseName, CurrentPerson ); | + | console.log( PersonalDataDataBaseName ); |
| | console.log( CurrentPerson ); | | console.log( CurrentPerson ); |
| | /* | | /* |
| Line 313: |
Line 317: |
| | inp_obj = record; | | inp_obj = record; |
| | } | | } |
| − | //give the value to the field to update
| + | //give the value to the field to update |
| − | inp_obj[field] = value; // => "Bob"
| + | inp_obj[field] = value; // => "Bob" |
| − | // write new version of record back to database
| + | // write new version of record back to database |
| − | store.put(inp_obj);
| + | store.put(inp_obj); |
| | | | |
| | | | |
| | // 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.name.user]); |
| − | getRecordAgain.onsuccess = function() {
| + | getRecordAgain.onsuccess = function() { |
| | console.log(getRecordAgain); // => "Bob" | | console.log(getRecordAgain); // => "Bob" |
| | if ( getRecordAgain.result[field] == value ) { | | if ( getRecordAgain.result[field] == value ) { |