I am trying to transfer entries from a mysql database (delivered by PHP via JSON) to a localforage db. The records listed under transactions are numbered with an id property (ascending from 1 to about 400 in the JSON string). My goal is to use these ids as keys for localforage. However the result is like shown in the screenshot from DevTools below.
var tmp, id;
var json = JSON.parse(data); // data is the JSON encoded string returned from server
for(var i = 0; i < json.transactions.length; i++){
tmp = json.transactions[i];
id = String(tmp.id);
console.log(typeof id);
delete tmp.id;
transactions.setItem(id, tmp).then(function (value) {
//console.log(value);
}).catch(function (err) {
console.log(err);
});
}
resulting database in localforage in DevTools (Screenshot)
How can I get localforage to use the correct ids (1, 2, 3, 4 ... 400 etc.) instead of these converted keys (that seem to descend from another number system)?