Skip to content

Is db_worker.js needed when SqliteConnection.synchronousWrapper(db) is used instead of SqliteDatabase(path: ..., ...)? #118

@andynewman10

Description

@andynewman10

I am currently using the following code:

final sqlite3 = await WasmSqlite3.loadFromUrl(Uri.parse('sqlite3.wasm'));
...
final db = sqlite3.open(...);
final db2 = SqliteDatabase.singleConnection(SqliteConnection.synchronousWrapper(db));
final query = await db2.execute("...."); // works fine

This works on both mobile and web (the code above is for the web).

When looking at your pub.dev page here, I see the following code illustrating the general case of database files:

import 'package:sqlite_async/sqlite_async.dart';

final db = SqliteDatabase(
    path: 'test.db',
    options: SqliteOptions(
        webSqliteOptions: WebSqliteOptions(
            wasmUri: 'sqlite3.wasm', workerUri: 'db_worker.js')));

What is db_worker.js for? When using SqliteDatabase.singleConnection(SqliteConnection.synchronousWrapper(db)), there is no opportunity/parameter to specify WebSqliteOptions. sqlite3.wasm has already been loaded (as shown above in the top code block), but shall db_worker.js be hosted on our application server, too, in this case? My tests show that the browser does not try to download that file, even though things work smoothly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions