do not ignore database version
This commit is contained in:
parent
8f180594fe
commit
6a57ad5fe2
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "idb-bridge",
|
"name": "idb-bridge",
|
||||||
"version": "0.0.4",
|
"version": "0.0.5",
|
||||||
"description": "IndexedDB implementation that uses SQLite3 as storage",
|
"description": "IndexedDB implementation that uses SQLite3 as storage",
|
||||||
"main": "./build/index.js",
|
"main": "./build/index.js",
|
||||||
"types": "./build/index.d.ts",
|
"types": "./build/index.d.ts",
|
||||||
|
@ -312,7 +312,7 @@ test("export", async t => {
|
|||||||
const backend = new MemoryBackend();
|
const backend = new MemoryBackend();
|
||||||
const idb = new BridgeIDBFactory(backend);
|
const idb = new BridgeIDBFactory(backend);
|
||||||
|
|
||||||
const request = idb.open("library");
|
const request = idb.open("library", 42);
|
||||||
request.onupgradeneeded = () => {
|
request.onupgradeneeded = () => {
|
||||||
const db = request.result;
|
const db = request.result;
|
||||||
const store = db.createObjectStore("books", { keyPath: "isbn" });
|
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.assert(exportedData.databases["library"].objectStores["books"].records.length === 3);
|
||||||
t.deepEqual(exportedData, exportedData2);
|
t.deepEqual(exportedData, exportedData2);
|
||||||
|
|
||||||
|
t.is(exportedData.databases["library"].schema.databaseVersion, 42);
|
||||||
t.pass();
|
t.pass();
|
||||||
});
|
});
|
@ -107,7 +107,7 @@ interface MemoryBackendDump {
|
|||||||
interface Connection {
|
interface Connection {
|
||||||
dbName: string;
|
dbName: string;
|
||||||
|
|
||||||
modifiedSchema: Schema | undefined;
|
modifiedSchema: Schema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the underlying database been deleted?
|
* Has the underlying database been deleted?
|
||||||
@ -491,6 +491,8 @@ export class MemoryBackend implements Backend {
|
|||||||
|
|
||||||
this.connectionsByTransaction[transactionCookie] = myConn;
|
this.connectionsByTransaction[transactionCookie] = myConn;
|
||||||
|
|
||||||
|
myConn.modifiedSchema.databaseVersion = newVersion;
|
||||||
|
|
||||||
return { transactionCookie };
|
return { transactionCookie };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,10 +527,7 @@ export class MemoryBackend implements Backend {
|
|||||||
if (!db) {
|
if (!db) {
|
||||||
throw Error("db not found");
|
throw Error("db not found");
|
||||||
}
|
}
|
||||||
if (myConn.modifiedSchema) {
|
return myConn.modifiedSchema;
|
||||||
return myConn.modifiedSchema;
|
|
||||||
}
|
|
||||||
return db.committedSchema;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renameIndex(
|
renameIndex(
|
||||||
@ -827,9 +826,7 @@ export class MemoryBackend implements Backend {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const schema = myConn.modifiedSchema
|
const schema = myConn.modifiedSchema;
|
||||||
? myConn.modifiedSchema
|
|
||||||
: db.committedSchema;
|
|
||||||
const objectStore = myConn.objectStoreMap[objectStoreName];
|
const objectStore = myConn.objectStoreMap[objectStoreName];
|
||||||
|
|
||||||
if (!objectStore.modifiedData) {
|
if (!objectStore.modifiedData) {
|
||||||
@ -1264,9 +1261,7 @@ export class MemoryBackend implements Backend {
|
|||||||
if (db.txLevel < TransactionLevel.Write) {
|
if (db.txLevel < TransactionLevel.Write) {
|
||||||
throw Error("only allowed while running a transaction");
|
throw Error("only allowed while running a transaction");
|
||||||
}
|
}
|
||||||
const schema = myConn.modifiedSchema
|
const schema = myConn.modifiedSchema;
|
||||||
? myConn.modifiedSchema
|
|
||||||
: db.committedSchema;
|
|
||||||
const objectStore = myConn.objectStoreMap[storeReq.objectStoreName];
|
const objectStore = myConn.objectStoreMap[storeReq.objectStoreName];
|
||||||
|
|
||||||
if (!objectStore.modifiedData) {
|
if (!objectStore.modifiedData) {
|
||||||
@ -1421,7 +1416,7 @@ export class MemoryBackend implements Backend {
|
|||||||
throw Error("only allowed while running a transaction");
|
throw Error("only allowed while running a transaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
db.committedSchema = myConn.modifiedSchema || db.committedSchema;
|
db.committedSchema = structuredClone(myConn.modifiedSchema);
|
||||||
db.txLevel = TransactionLevel.Connected;
|
db.txLevel = TransactionLevel.Connected;
|
||||||
|
|
||||||
db.committedIndexes = {};
|
db.committedIndexes = {};
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
"typeRoots": ["./node_modules"],
|
||||||
"types": []
|
"types": []
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"]
|
"include": ["src/**/*"]
|
||||||
|
Loading…
Reference in New Issue
Block a user