@better-duck/tauri exposes a single default export — the Database class.
Each method wraps one plugin command via invoke('plugin:better-duck-tauri|<command>', …), so the
class is a typed, ergonomic front for the command set.
Lifecycle
ADatabase is a handle to one loaded connection. You obtain it with the static load, and release
it with close.
Database.load(path)invokesloadand returns aDatabasewhosepathis the connection string you passed.pathis the identifier sent asdbto every subsequent command.db.close()invokesclose, dropping the registered connection, and resolves to aboolean(whether one was open).
load is also where migrations run for a registered connection string, through the crash-safe
backup protocol on disk. See Migrations.Connection strings
Thepath you pass to Database.load is resolved on the Rust side by stripping a leading
duckdb: prefix:
The method map
Every command takes
db: this.path as its first argument automatically; you only pass the
operation-specific arguments.
Error handling
The plugin’s RustError serializes to the webview as a plain string, so the invoke promise
rejects with that string. There are four underlying kinds:
Value mapping
Parameters (JS → DuckDB)
values bind as positional $1, $2, …:
Results (DuckDB → JS)
Rows come back as JSON objects keyed by column name. Most types map directly; precision-sensitive ones are preserved as strings so they survive JSnumber limits:
For the full DuckDB type system you query through this plugin, see
Queries & values.
See also
- Query & execute — the core read/write pair.
- Capabilities & permissions — only
load/close/selectare granted by default; everything else is opt-in.