While I may not be a JSON expert, I am struggling to understand why this code is not functioning as expected and what steps I need to take to fix it. Despite my efforts to search for solutions, I suspect that my lack of familiarity with the correct terminology is hindering me. My goal is to call a function and, within that function, create a JSON object to store in an IndexedDB "table" like the following:
UpdateSettingsValue("initialized", true);
function UpdateSettingsValue(key, value){
var tx = db.transaction(["settings"], "readwrite");
var store = tx.objectStore("settings");
var trans = {
key:value
}
var request = store.add(trans);
}
Although this script successfully creates an entry, it saves it as {key: true}
.
Therefore, my query is how can I alter it to save as {initialized: true}
instead?
I appreciate your assistance!