idb-map-entries
Advanced tools
Comparing version 0.3.1 to 0.3.2
17
index.js
@@ -48,3 +48,12 @@ const { assign } = Object; | ||
} | ||
async getVersion(name) { | ||
let version = 0; | ||
const databases = await indexedDB.databases(); | ||
for (const db of databases) { | ||
if (db.name === name) { | ||
version = db.version; | ||
} | ||
} | ||
return version; | ||
} | ||
/** | ||
@@ -65,8 +74,8 @@ * @param {string} name | ||
this.#options = { durability }; | ||
this.#db = new Promise((resolve, reject) => { | ||
this.#db = new Promise(async (resolve, reject) => { | ||
assign( | ||
indexedDB.open(this.#prefix), | ||
indexedDB.open(this.#prefix, await this.getVersion(this.#prefix) + 1), | ||
{ | ||
onupgradeneeded({ target: { result, transaction } }) { | ||
if (!result.objectStoreNames.length) | ||
if (!result.objectStoreNames.contains(name)) | ||
result.createObjectStore(name); | ||
@@ -73,0 +82,0 @@ transaction.oncomplete = () => resolve(result); |
{ | ||
"name": "idb-map-entries", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"type": "module", | ||
@@ -11,2 +11,7 @@ "main": "index.js", | ||
], | ||
"scripts": { | ||
"build": "npm run build:index && npm run build:sync", | ||
"build:index": "ascjs --no-default index.js index.cjs", | ||
"build:sync": "ascjs --no-default sync.js sync.cjs && sed -i 's/index\\.js/index\\.cjs/' sync.cjs" | ||
}, | ||
"exports": { | ||
@@ -36,8 +41,3 @@ ".": { | ||
"ascjs": "^6.0.3" | ||
}, | ||
"scripts": { | ||
"build": "npm run build:index && npm run build:sync", | ||
"build:index": "ascjs --no-default index.js index.cjs", | ||
"build:sync": "ascjs --no-default sync.js sync.cjs && sed -i 's/index\\.js/index\\.cjs/' sync.cjs" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
18685
446