tôi phải thừa nhận rằng tôi rất mới để IndexedDBcủa router InvalidStateError: Không thực thi 'giao dịch' bật 'IDBDatabase': Một giao dịch phiên bản thay đổi đang chạy
Tôi đã viết một mã đơn giản của indexedDB
và nó được như sau:
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;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)}
}}
lỗi nó đem lại cho tôi là Uncaught InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.
người ta nói rằng A version change Transaction is running
nhưng như xa như tôi đã nghiên cứu, một giao dịch phiên bản thay đổi được làm từ IDBFactory.open
phương pháp và tôi đã không sử dụng và tôi đã chỉ định rằng giao dịch này là readwrite
và giao dịch này là trong onupgradeneeded
thì tại sao có lỗi?
tôi phải thừa nhận rằng tôi rất mới đối với indexedDB
nhưng làm thế nào để xác định khoảng thời gian giao dịch ? –
và nó cho tôi một lỗi 'Uncaught NotFoundError: Không thể thực thi 'objectStore' trên 'IDBTransaction': Không tìm thấy kho lưu trữ đối tượng đã chỉ định.' trên dòng' transaction.objectStore ('text') ' –