mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
fix: SQLSeal now work with multiple vaults open at the same time
This commit is contained in:
parent
91584fe9f9
commit
9b4f5c137f
3 changed files with 11 additions and 5 deletions
|
|
@ -6,7 +6,7 @@ If you are developing SQLSeal you might encounter one of few common issues.
|
|||
If you've been modifying your database and you end up with invalid schema, and want to reset the database (or want to reset the database for any other reason):
|
||||
- Open Dev Tools
|
||||
- Go to Applications
|
||||
- Open Storage -> IndexedDb -> sqlite.db
|
||||
- Open Storage -> IndexedDb -> sqlseal__x.sqlite3 (the x is a name of your vault and unique vault id. If you use multiple vaults, locate the one with the matching name)
|
||||
- Click Delete Database
|
||||
- Reload Obsidian (choose Reload from command palette)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import * as Comlink from 'comlink'
|
|||
// @ts-ignore
|
||||
import workerCode from 'virtual:worker-code'
|
||||
import { WorkerDatabase } from "./worker/database";
|
||||
import { sanitise } from "../utils/sanitiseColumn";
|
||||
|
||||
export class SqlSealDatabase {
|
||||
db: Comlink.Remote<WorkerDatabase>
|
||||
|
|
@ -35,7 +36,9 @@ export class SqlSealDatabase {
|
|||
});
|
||||
const DatabaseWrap = Comlink.wrap<typeof WorkerDatabase>(worker)
|
||||
|
||||
const instance = await new DatabaseWrap()
|
||||
const filename = sanitise(this.app.vault.getName()) + '___' + (this.app as any).appId
|
||||
|
||||
const instance = await new DatabaseWrap(filename)
|
||||
|
||||
await instance.connect()
|
||||
this.db = instance
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export class WorkerDatabase {
|
|||
|
||||
private db: Database
|
||||
|
||||
constructor() {
|
||||
constructor(private readonly dbName: string) {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -191,13 +191,16 @@ export class WorkerDatabase {
|
|||
SQL.FS.mkdir('/sql');
|
||||
SQL.FS.mount(sqlFS, {}, '/sql');
|
||||
|
||||
const path = 'sql/sqlseal.sqlite';
|
||||
// Removing old database under the generic name
|
||||
indexedDB.deleteDatabase('sqlseal.sqlite')
|
||||
|
||||
const path = `sql/sqlseal___${this.dbName}.sqlite3`
|
||||
|
||||
let stream = SQL.FS.open(path, 'a+');
|
||||
await stream.node.contents.readIfFallback();
|
||||
SQL.FS.close(stream);
|
||||
|
||||
const db = new SQL.Database('sql/sqlseal.sqlite', { filename: true });
|
||||
const db = new SQL.Database(path, { filename: true });
|
||||
|
||||
let cacheSize = 0;
|
||||
let pageSize = 4096;
|
||||
|
|
|
|||
Loading…
Reference in a new issue