openDatabase method

  1. @override
Future<WorkerDatabase> openDatabase(
  1. WasmSqlite3 sqlite3,
  2. String path,
  3. String vfs,
  4. JSAny? additionalData,
)
override

Opens a database in the pre-configured sqlite3 instance under the specified path in the given vfs.

This should virtually always call sqlite3.open(path, vfs: vfs) and wrap the result in a WorkerDatabase subclass.

The additionalData can be set by clients when opening the database. It might be useful to transport additional options relevant when opening the database.

Implementation

@override
Future<WorkerDatabase> openDatabase(WasmSqlite3 sqlite3, String path,
    String vfs, JSAny? additionalData) async {
  final db = openUnderlying(sqlite3, path, vfs, additionalData);

  // Register any custom functions here if needed

  final throttled = ThrottledCommonDatabase(db);

  return AsyncSqliteDatabase(database: throttled);
}