Documentation
¶
Rendered for js/wasm
Overview ¶
Package main provides the WASM entry point for the WasmDB database. It initializes the IndexedDB-backed Nostr event store and exposes the database API to JavaScript via the global `wasmdb` object.
Build with:
GOOS=js GOARCH=wasm go build -o wasmdb.wasm ./cmd/wasmdb
Usage in JavaScript:
// Load wasm_exec.js first (Go WASM runtime)
const go = new Go();
const result = await WebAssembly.instantiateStreaming(fetch('wasmdb.wasm'), go.importObject);
go.run(result.instance);
// Wait for ready
while (!wasmdb.isReady()) {
await new Promise(resolve => setTimeout(resolve, 100));
}
// Use the API
await wasmdb.saveEvent(JSON.stringify(event));
const events = await wasmdb.queryEvents(JSON.stringify({kinds: [1], limit: 10}));
Source Files
¶
- main.go
Click to show internal directories.
Click to hide internal directories.