Skip to content

Commit

Permalink
Database._open: remove remains of storage support
Browse files Browse the repository at this point in the history
  • Loading branch information
tanriol committed Apr 28, 2024
1 parent 43b0fa3 commit adab770
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions modules/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,12 @@ export let Database = {
return this;
},

async _open({name="brief", version=undefined, storage="default", upgrade=null}) {
let description = `database in ${storage} storage`;
async _open({name="brief", version=undefined, upgrade=null}) {
let canUpgrade = (upgrade !== null);
console.log(`Brief: opening ${description}${ canUpgrade ? " with upgrade" : "" }`);
let openOptions = version;
if(storage === 'persistent') {
openOptions = {
storage: 'persistent',
version,
};
}
console.log(`Brief: opening database${ canUpgrade ? " with upgrade" : "" }`);
let db;
let upgradeFrom;
let opener = indexedDB.open(name, openOptions);
let opener = indexedDB.open(name, version);
if(upgrade !== null) {
opener.onupgradeneeded = (event) => upgrade(event);
} else {
Expand All @@ -148,16 +140,16 @@ export let Database = {
} catch(e) {
if(e.name === "AbortError" && !canUpgrade) {
if(upgradeFrom === 0) {
console.info(`Found no ${description}`);
console.info(`Found no database`);
} else {
console.info(`The ${description} needs upgrade, aborting`);
console.info(`The database needs upgrade, aborting`);
}
} else {
console.error("Error opening database:", e.name, e.message);
}
return null;
}
console.log(`Brief: opened ${description}`);
console.log(`Brief: opened database`);
return db;
},

Expand Down

0 comments on commit adab770

Please sign in to comment.