Proper init for IDBBatchAtomicVFS #50
-
Is this configuration correct? I'm not sure about export const initDb: TaskEither<UnknownError, Database> = taskEither.tryCatch(
async () => {
const asyncModule = await SQLiteAsyncESMFactory();
const sqlite3 = SQLite.Factory(asyncModule);
sqlite3.vfs_register(
new IDBBatchAtomicVFS("dbName", { durability: "relaxed" })
);
const connection = await sqlite3.open_v2(
"myAppName",
SQLite.SQLITE_OPEN_CREATE |
SQLite.SQLITE_OPEN_READWRITE |
SQLite.SQLITE_OPEN_URI,
"dbName"
);
await sqlite3.exec(connection, `PRAGMA journal_mode=delete;`);
return { connection, sqlite3 };
},
(error): UnknownError => ({ type: "UnknownError", error })
); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It looks fine to me. The default The default open flags are CREATE | READWRITE so if you don't really need URI then you could just pass |
Beta Was this translation helpful? Give feedback.
It looks fine to me. The default
journal_mode
isdelete
, so thatPRAGMA
isn't necessary unless it's a placeholder to try a different setting later.The default open flags are CREATE | READWRITE so if you don't really need URI then you could just pass
undefined
. Adding URI doesn't hurt anything but you might not need it - the reasons to use it are to pass extra parameters to the VFS (which IDBBatchAtomic doesn't use) and that it enables passing a URI toATTACH DATABASE
statements, which can be handy if you need it, e.g. to attach another database read-only, with a non-default VFS, or with VFS-specific parameters.