@samtv12345/ueberdb-rs
v0.1.0
Published
Transform every database into an object key value store (Rust port)
Readme
@samtv12345/ueberdb-rs
Drop-in replacement for ueberdb2 — the
multi-backend key/value abstraction Etherpad uses — re-implemented in safe
Rust behind a napi-rs binding. Same Database JS class,
same Settings shape, same Promise-returning method surface. Distributed
as a single fat .node per platform with all 14 driver crates linked in.
Features
A single Database class wraps a Backend trait plus a wrapper layer:
- LRU read-cache (moka) with per-Settings capacity
- Coalescing write-buffer with periodic flush,
do_bulkbatching, and a snapshot/commit drain that's safe under concurrent backend updates - Per-key locks so different keys make progress in parallel while writes to the same key stay serialized
getSub/setSubfor nested JSON, with TS-parity semantics (passingundefineddeletes the leaf)findKeysglob translation; backends with native pattern matching short-circuit- Atomic counters for reads/writes/cache hits/flushes/bulks via
db.metrics()
Backends
All 14 ueberDB backends are ported. Each row is exercised by the same vitest conformance suite (memory and dirty-style backends from ueberDB plus per-backend testcontainers specs).
| type arg | Crate / driver | Native pattern matching |
| ------------------- | --------------------- | ----------------------- |
| memory | HashMap + RwLock | wrapper-side |
| dirty | append-log file | wrapper-side |
| dirty_git | dirty + git2 | wrapper-side |
| sqlite | sqlx (sqlite) | LIKE |
| rusty / rustydb | redb | wrapper-side |
| postgres | tokio-postgres | LIKE |
| postgrespool | tokio-postgres+bb8| LIKE |
| mysql / mariadb | sqlx (mysql) | LIKE |
| mssql | tiberius | LIKE |
| mongodb | mongodb | regex |
| redis | redis | SCAN MATCH |
| couch | reqwest (HTTP API) | wrapper-side |
| cassandra | scylla | wrapper-side |
| elasticsearch | reqwest (HTTP API) | wildcard query |
| surrealdb | reqwest (HTTP API) | wrapper-side |
JS API
import { Database } from '@samtv12345/ueberdb-rs'
const db = new Database('postgres', {
host: 'localhost',
user: 'ueberdb',
password: 'ueberdb',
database: 'ueberdb',
}, {
cache: 1000, // LRU capacity (0 disables)
writeInterval: 100, // ms between background flushes (0 disables)
bulkLimit: 100, // max ops per bulk flush
})
await db.init()
await db.set('key', { a: 1 })
const value = await db.get('key')
const keys = await db.findKeys('key:*', null)
await db.setSub('key', ['a'], 2)
await db.flush()
await db.close()Testing
The conformance suite under __test__/ is a port of ueberDB's test/lib,
parameterized over {readCache, writeBuffer} × per-backend container, and
runs ~80 cases per backend. The networked specs spin up the right Docker
image via testcontainers.
pnpm install
pnpm build:debug
pnpm test # all backends
pnpm test __test__/sqlite.spec.ts # one backend
cargo test --lib # Rust unit tests for the wrapper layerStatus
@samtv12345/ueberdb-rs is a fresh package name; the legacy TypeScript implementation
keeps publishing under ueberdb2 until consumers have migrated. The CI
matrix exercises every backend's conformance spec on each push.
License
Apache-2.0
