Node Quick Start
TaiDB does not currently ship an official npm package. The recommended Node
path is a small CLI bridge around the public taidb binary. This keeps the
repository source-only and avoids platform package maintenance until native
Node support is justified.
Install TaiDB
Section titled “Install TaiDB”Install the CLI once:
cargo install taidbConfirm Node can find it:
taidb --helpCreate a Node script
Section titled “Create a Node script”Create index.mjs:
import { spawnSync } from "node:child_process";
const db = "./node.taidb";
function runTaiDB(...args) { const result = spawnSync("taidb", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], });
if (result.status !== 0) { throw new Error(result.stderr || `taidb failed: ${args.join(" ")}`); }
return result.stdout.trim();}
runTaiDB("put", db, "user:1", "Alice");runTaiDB("vector-put", db, "vec:1", "0.1,0.9,0.2");runTaiDB("vector-put", db, "vec:2", "0.9,0.1,0.1");
console.log(runTaiDB("get", db, "user:1"));console.log(runTaiDB("vector-search", db, "0.0,1.0,0.2", "--limit", "1"));Run:
node index.mjsWrap common operations
Section titled “Wrap common operations”For application code, hide process spawning behind a small module:
import { spawnSync } from "node:child_process";
export class TaiDB { constructor(path, binary = "taidb") { this.path = path; this.binary = binary; }
exec(...args) { const result = spawnSync(this.binary, args, { encoding: "utf8" }); if (result.status !== 0) { throw new Error(result.stderr || `${this.binary} exited ${result.status}`); } return result.stdout.trim(); }
put(key, value) { this.exec("put", this.path, key, value); }
get(key) { const value = this.exec("get", this.path, key); return value.length ? value : null; }
searchVector(vector, limit = 5) { return this.exec( "vector-search", this.path, vector.join(","), "--limit", String(limit), ); }}When to avoid the CLI bridge
Section titled “When to avoid the CLI bridge”The bridge is simple and portable, but it is not ideal for high-frequency calls inside a hot request path. If you need thousands of operations per second from Node, use Rust directly, build a native binding, or design a long-running local process around your workload.
The roadmap keeps official npm native packaging out of 1.0.0 unless the
maintenance cost is justified by real users and benchmarks.
For Python, Go, Ruby, PHP, Bash, and Java examples, see the Other Languages page.