From 069c4c76c3e15f12e74de7b8b151b4ba1839856c Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Sat, 16 Sep 2023 13:26:05 +0200 Subject: [PATCH] Describe how to open an in-memory wasm database --- drift/lib/wasm.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drift/lib/wasm.dart b/drift/lib/wasm.dart index 28ff49aa..5f23a38e 100644 --- a/drift/lib/wasm.dart +++ b/drift/lib/wasm.dart @@ -63,6 +63,19 @@ class WasmDatabase extends DelegatedDatabase { } /// Creates an in-memory database in the loaded [sqlite3] database. + /// + /// If an in-memory database is all you need, it can be created more easily + /// than going through the path with [open]. In particular, you probably don't + /// need a web worker hosting the database. + /// + /// To create an in-memory database without workers, one can use: + /// + /// ```dart + /// final sqlite3 = await WasmSqlite3.loadFromUrl(Uri.parse('/sqlite3.wasm')); + /// sqlite3.registerVirtualFileSystem(InMemoryFileSystem(), makeDefault: true); + /// + /// WasmDatabase.inMemory(sqlite3); + /// ``` factory WasmDatabase.inMemory( CommonSqlite3 sqlite3, { WasmDatabaseSetup? setup,