You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Applications should import the Emscripten module factory and the SQLite API:
// Emscripten module factory (most applications use only one)importSQLiteESMFactoryfrom"wa-sqlite/dist/wa-sqlite.mjs";importSQLiteAsyncESMFactoryfrom"wa-sqlite/dist/wa-sqlite-async.mjs";// SQLite API constants and functionsimport*asSQLitefrom'wa-sqlite';
Most applications will only use one of the Emscripten builds, either the synchronous build or the asynchronous build. See this question for an explanation of the difference.
The Emscripten module factory is a function that asynchronously loads, compiles, and initializes the corresponding WebAssembly file. Both the module (.mjs) and WebAssembly (.wasm) files are located in the dist/ subdirectory of the wa-sqlite package. If the Emscripten module factory is called with no arguments, then the .wasm file will be loaded from the same directory path as the .mjs file, e.g.:
constmodule=awaitSQLiteESMFactory();
That works fine if you're serving the Emscripten module as-is to the browser but bundling can complicate matters (especially when targeting a Worker). If you need the ability to explicitly specify the .wasm URL, do that by passing a configuration argument to the Emscripten module factory:
constmodule=awaitSQLiteESMFactory({// When provided a filename, return the URL for that filename.// This example uses the same directory as the document.locateFile(file){return`./${file}`;}});
Once you have an Emscripten module instance, you can create an API instance:
constsqlite3=SQLite.Factory(module);// And you're off and running...constdb=awaitsqlite3.open_v2('myDB');
...
Applications should import the Emscripten module factory and the SQLite API:
Most applications will only use one of the Emscripten builds, either the synchronous build or the asynchronous build. See this question for an explanation of the difference.
The Emscripten module factory is a function that asynchronously loads, compiles, and initializes the corresponding WebAssembly file. Both the module (.mjs) and WebAssembly (.wasm) files are located in the dist/ subdirectory of the wa-sqlite package. If the Emscripten module factory is called with no arguments, then the .wasm file will be loaded from the same directory path as the .mjs file, e.g.:
That works fine if you're serving the Emscripten module as-is to the browser but bundling can complicate matters (especially when targeting a Worker). If you need the ability to explicitly specify the .wasm URL, do that by passing a configuration argument to the Emscripten module factory:
Once you have an Emscripten module instance, you can create an API instance:
See also the reference docs.
The text was updated successfully, but these errors were encountered: