Comparing version 5.0.4 to 5.0.5
@@ -28,2 +28,34 @@ import { b as openDB, c as dbName, g as getNextVersion, w as wrap, u as unwrap, o as openDBWithSchema, d as deleteDatabase } from './utils-66091b10.js'; | ||
}); | ||
test('open without version - upgrade should not run', async () => { | ||
let upgradeRun = false; | ||
db = (await openDB(dbName, undefined, { | ||
upgrade(db, oldVersion, newVersion, tx) { | ||
upgradeRun = true; | ||
}, | ||
})); | ||
assert.isFalse(upgradeRun, 'upgrade not run'); | ||
assert.strictEqual(db.version, 1); | ||
}); | ||
test('open without version - database never existed', async () => { | ||
db = (await openDB(dbName)); | ||
assert.strictEqual(db.version, 1); | ||
}); | ||
test('open with undefined version - database never existed', async () => { | ||
db = (await openDB(dbName, undefined, {})); | ||
assert.strictEqual(db.version, 1); | ||
}); | ||
test('open without version - database previously created', async () => { | ||
const version = getNextVersion(); | ||
db = (await openDB(dbName, version)); | ||
db.close(); | ||
db = (await openDB(dbName)); | ||
assert.strictEqual(db.version, version); | ||
}); | ||
test('open with undefined version - database previously created', async () => { | ||
const version = getNextVersion(); | ||
db = (await openDB(dbName, version)); | ||
db.close(); | ||
db = (await openDB(dbName, undefined, {})); | ||
assert.strictEqual(db.version, version); | ||
}); | ||
test('upgrade - schemaless', async () => { | ||
@@ -30,0 +62,0 @@ let upgradeRun = false; |
{ | ||
"name": "idb", | ||
"version": "5.0.4", | ||
"version": "5.0.5", | ||
"description": "A small wrapper that makes IndexedDB usable", | ||
@@ -5,0 +5,0 @@ "main": "build/cjs/index.js", |
@@ -22,2 +22,4 @@ # IndexedDB with usability. | ||
## Using npm | ||
```sh | ||
@@ -37,4 +39,6 @@ npm install idb | ||
Or, use it directly via unpkg: | ||
## Directly In a browser | ||
### Using the modules method directly via unpkg: | ||
```html | ||
@@ -50,2 +54,13 @@ <script type="module"> | ||
### Using external script reference | ||
```html | ||
<script src="https://unpkg.com/idb@5/build/iife/index-min.js"></script> | ||
<script> | ||
async function doDatabaseStuff() { | ||
const db = await idb.openDB(…); | ||
} | ||
</script> | ||
``` | ||
# Changes | ||
@@ -79,3 +94,3 @@ | ||
- `name`: Name of the database. | ||
- `version`: Schema version. | ||
- `version` (optional): Schema version, or `undefined` to open the current version. | ||
- `upgrade` (optional): Called if this version of the database has never been opened before. Use it to specify the schema for the database. This is similar to the [`upgradeneeded` event](https://developer.mozilla.org/en-US/docs/Web/API/IDBOpenDBRequest/upgradeneeded_event) in plain IndexedDB. | ||
@@ -82,0 +97,0 @@ - `db`: An enhanced `IDBDatabase`. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1317755
30750
491
1