problem description
I need to dynamically add the "table" (store), of indexddb
to the project instead of initializing all the tables to be used at once. However, there is a problem when triggering the version update event, and the crux of the problem is as follows:
the code is as follows
const one = window.indexedDB.open("test");
one.onupgradeneeded = e => {
console.log("db one upgrade success", e.target.readyState);
updateDB();
}
function updateDB() {
const tow = window.indexedDB.open("test", 2);
tow.onupgradeneeded = e => {
console.log("db tow upgrade success", e.target.readyState);
}
tow.onblocked = e => {
console.log("blocked:", e)
}
setTimeout(() => {
console.log(tow.readyState);
}, 3000);
}
running results
questions
after creating the database, update the database version and expect some action in the upgradeneeded
event, but the second operation is suspended and cannot trigger the upgradeneeded
event. In fact, success
and error
are not triggered either. Could you tell me how to solve this situation?