aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/idb-bridge/package.json2
-rw-r--r--packages/idb-bridge/src/MemoryBackend.test.ts3
-rw-r--r--packages/idb-bridge/src/MemoryBackend.ts19
-rw-r--r--packages/idb-bridge/tsconfig.json1
4 files changed, 11 insertions, 14 deletions
diff --git a/packages/idb-bridge/package.json b/packages/idb-bridge/package.json
index a91b5f263..5816b7172 100644
--- a/packages/idb-bridge/package.json
+++ b/packages/idb-bridge/package.json
@@ -1,6 +1,6 @@
{
"name": "idb-bridge",
- "version": "0.0.4",
+ "version": "0.0.5",
"description": "IndexedDB implementation that uses SQLite3 as storage",
"main": "./build/index.js",
"types": "./build/index.d.ts",
diff --git a/packages/idb-bridge/src/MemoryBackend.test.ts b/packages/idb-bridge/src/MemoryBackend.test.ts
index 41bf1986a..7f9c1440d 100644
--- a/packages/idb-bridge/src/MemoryBackend.test.ts
+++ b/packages/idb-bridge/src/MemoryBackend.test.ts
@@ -312,7 +312,7 @@ test("export", async t => {
const backend = new MemoryBackend();
const idb = new BridgeIDBFactory(backend);
- const request = idb.open("library");
+ const request = idb.open("library", 42);
request.onupgradeneeded = () => {
const db = request.result;
const store = db.createObjectStore("books", { keyPath: "isbn" });
@@ -344,5 +344,6 @@ test("export", async t => {
t.assert(exportedData.databases["library"].objectStores["books"].records.length === 3);
t.deepEqual(exportedData, exportedData2);
+ t.is(exportedData.databases["library"].schema.databaseVersion, 42);
t.pass();
}); \ No newline at end of file
diff --git a/packages/idb-bridge/src/MemoryBackend.ts b/packages/idb-bridge/src/MemoryBackend.ts
index 4154435a0..b904dd040 100644
--- a/packages/idb-bridge/src/MemoryBackend.ts
+++ b/packages/idb-bridge/src/MemoryBackend.ts
@@ -107,7 +107,7 @@ interface MemoryBackendDump {
interface Connection {
dbName: string;
- modifiedSchema: Schema | undefined;
+ modifiedSchema: Schema;
/**
* Has the underlying database been deleted?
@@ -491,6 +491,8 @@ export class MemoryBackend implements Backend {
this.connectionsByTransaction[transactionCookie] = myConn;
+ myConn.modifiedSchema.databaseVersion = newVersion;
+
return { transactionCookie };
}
@@ -525,10 +527,7 @@ export class MemoryBackend implements Backend {
if (!db) {
throw Error("db not found");
}
- if (myConn.modifiedSchema) {
- return myConn.modifiedSchema;
- }
- return db.committedSchema;
+ return myConn.modifiedSchema;
}
renameIndex(
@@ -827,9 +826,7 @@ export class MemoryBackend implements Backend {
);
}
- const schema = myConn.modifiedSchema
- ? myConn.modifiedSchema
- : db.committedSchema;
+ const schema = myConn.modifiedSchema;
const objectStore = myConn.objectStoreMap[objectStoreName];
if (!objectStore.modifiedData) {
@@ -1264,9 +1261,7 @@ export class MemoryBackend implements Backend {
if (db.txLevel < TransactionLevel.Write) {
throw Error("only allowed while running a transaction");
}
- const schema = myConn.modifiedSchema
- ? myConn.modifiedSchema
- : db.committedSchema;
+ const schema = myConn.modifiedSchema;
const objectStore = myConn.objectStoreMap[storeReq.objectStoreName];
if (!objectStore.modifiedData) {
@@ -1421,7 +1416,7 @@ export class MemoryBackend implements Backend {
throw Error("only allowed while running a transaction");
}
- db.committedSchema = myConn.modifiedSchema || db.committedSchema;
+ db.committedSchema = structuredClone(myConn.modifiedSchema);
db.txLevel = TransactionLevel.Connected;
db.committedIndexes = {};
diff --git a/packages/idb-bridge/tsconfig.json b/packages/idb-bridge/tsconfig.json
index 017afdae1..8baf78ac1 100644
--- a/packages/idb-bridge/tsconfig.json
+++ b/packages/idb-bridge/tsconfig.json
@@ -10,6 +10,7 @@
"strict": true,
"incremental": true,
"sourceMap": true,
+ "typeRoots": ["./node_modules"],
"types": []
},
"include": ["src/**/*"]