2
I am using this library to perform Indexeddb functions more easily:
Dexie
But the code does not in any way follow the execution order and that makes my script does not work.
Example
This code is just an example to show that it does not follow the execution order, where you can watch the browser console while doing refresh to the page:
See on the Jsfiddle.
var db = new Dexie('teste');
var atual_sequence = 0;
db.version(1).stores({sequences: '++id,of'});
db.open().catch(function(error){
});
db.sequences.where("of").equalsIgnoreCase('0').count(function (count) {
atual_sequence = count;
console.warn(atual_sequence);
});
db.sequences.add({of: '0'});
console.log('ds: '+atual_sequence);
He executes the console.log('ds: '+atual_sequence);
before obtaining the sequence number, is there any way to correct this?