A notes CLI over a fennec-server, from Node, through
@fennecdb/web/client: the query builder and the HTTP client alone. No
WebAssembly is fetched or loaded; every query runs on the server.
- the schema declared in code, Drizzle's way (
src/tables.ts,fennecTablefrom@fennecdb/web/schema), brought to the server byconnect(url, { schema, migrate: true }), and four notes seeded into an empty collection; - every query typed by the table: a misspelt field is a compile error;
- creating notes, and marking one done;
- full-text search with
match, fused withnearover a toy embedding (fuse); - filtering by tag (
tags has) or bydone, newest first; watch: a live query over the server --db.live(query, cb)runs the query there again after every write tonotes;smokechecks that no request was for a.wasm.
Node 22 or newer, and fennec-server: a release
binary, or
cargo build --release -p fennec-server at the repository's root
(target/release/fennec-server).
fennec-server --file notes.fennec --http 127.0.0.1:8080 --http-token secretcd examples/node-server
npm install
npm start # seeds, then lists
npm start -- add "Dentist" "Call the dentist on Monday." health
npm start -- list --tag home
npm start -- list --open
npm start -- search istanbul trip # match, then fuse
npm start -- done 1
npm start -- watch # Ctrl-C to stop; add a note from another terminal
npm run smoke # type-checks, then the whole tour, checked: what CI runsFENNEC_URL and FENNEC_TOKEN point it at another server; secret is a
development default, never one to deploy.
import { connect } from '@fennecdb/web/client'; // no engine, no .wasm
import { notes, embed } from './tables.js'; // fennecTable('notes', { ... })
const db = await connect(url, { token, schema: { notes }, migrate: true });
await db.from(notes).insert({ title, body, tags: ['home'], done: false, at: new Date(), embed: embed(`${title} ${body}`) });
const open = db.from(notes).where('done', false).order('at', 'desc');
db.live(open, (rows) => show(rows)); // again after every write to notes
await db.from(notes).match('body', words).near('embed', embed(words)).fuse().limit(5).rows();
await db.from(notes).where('id', id).update({ done: true });embed() in src/tables.ts is a placeholder, not a model: character
trigrams (of the UTF-8 bytes) hashed into 64 dimensions with FNV-1a, so
near and fuse have something to rank without a download. It matches
spelling, not meaning; every Notes example computes the same vectors. A
real app calls a model here -- an embeddings API, or transformers.js's
pipeline('feature-extraction', ...) -- and declares
vector({ dimensions: N }) with that model's N.
CI installs @fennecdb/web packed from web/ in this checkout rather than
npm's: examples/run-tests.sh node-server copies the folder, points the
dependency at the tarball (npm pkg set dependencies.@fennecdb/web=file:...),
installs, and runs npm run smoke against a fennec-server it builds and
starts.