@dreaminhex/hexdb
The JavaScript and TypeScript client for HexDB, a document database with REST, GraphQL and read-only SQL, encryption at rest and replication with automatic failover.
It covers documents (insert, get, replace, patch, delete), queries with filters, sorting and paging, counts, aggregations, upserts, detokenizing vault tokens, transactions, idempotency keys, the change feed, streams, functions and GraphQL. It retries 429 and 503 answers for reads, and for writes that carry an idempotency key. Runs on Node.js 18+, Deno, Bun and in browsers, with no dependencies.
npm install @dreaminhex/hexdb
import { HexDB } from "@dreaminhex/hexdb"
const db = new HexDB({ url: "http://127.0.0.1:7700", apiKey: process.env.HEXDB_API_KEY })
const orders = db.tessellation("orders")
await orders.insert({ customer: "ada", total: 12 })
const page = await orders.query({ filter: { total: { $gt: 10 } }, sort: "-total" })
Create an API key on the admin UI's Account page. A connection URI works too, the same one the other HexDB drivers take:
const db = new HexDB(process.env.HEXDB_URI!) // e.g. hexdbs://db.example.com?apiKey=hxk_...
const db2 = await HexDB.connect("hexdbs://ada:[email protected]") // signs in now; new HexDB(uri) signs in on first use
parseConnectionUri and redactConnectionUri are exported for tools that store URIs. The driver documentation and the manual cover the rest. Licensed under the Apache License 2.0.