i must admit that i am very new to indexedDB
I wrote a simple code of indexedDB
and it is as followed:
function go() {
var req = window.indexedDB.open("Uploader", 1),
db;
req.onerror = function (e) {
console.log("Error");
};
req.onsuccess = function (e) {
db = e.target.result;
};
req.onupgradeneeded = function (e) {
console.log(db);
db = e.target.result;
var os = db.createObjectStore("Files", { keyPath: "files" });
os.createIndex("text", "text_file", { unique: false });
var trans = db.transaction(["text"], "readwrite");
var objectstore = trans.objectStore("text");
var addreq = objectstore.add("Instructions.js");
addreq.onsuccess = function (e) {
console.log("Success!");
console.dir(e);
};
};
}
the error it is giving me is Uncaught InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.
It is saying that A version change Transaction is running
but as far as i have studied, a version change transaction is made from IDBFactory.open
method and i haven't used and i have specified that this transaction is readwrite
and this transaction is in onupgradeneeded
then why there is an error?
i must admit that i am very new to indexedDB