zdb-engine-wasm
v0.1.0
Published
A WebAssembly engine for the ZDB SDK
Readme
zdb-engine-wasm
A WebAssembly engine for the ZDB SDK.
This library is a plugin for the ZDB SDK, which can be used to run ZDB as an embedded database within a browser environment, not server side environments.
It enables ZDB to be run in-memory, or to persist data by running on top of IndexedDB. It allows for a consistent JavaScript and TypeScript API when using the zdb-sdk library for javascript by adding support for embedded storage engines (memory, indxdb) alongside the remote connection protocols (http, https, ws, wss).
This library works with ES modules (import), not CommonJS (require).
Example usage
import { Z } from "zdb-sdk";
import { engine } from "zdb-engine-wasm";
// Enable the WebAssembly engines
const db = new Z({
engines: engine(),
});
// Now we can start ZDB as an in-memory database
await db.connect("mem://");
// Or we can start a persisted IndexedDB database
await db.connect("indxdb://demo");
// Now use the JavaScript SDK as normal.Usage with Vite
When using Vite the following configuration is recommended to be placed in your vite.config.ts
optimizeDeps: {
exclude: ["zdb-engine-wasm"],
esbuildOptions: {
target: "esnext",
},
},
esbuild: {
supported: {
"top-level-await": true
},
}