Skip to content

Latest commit

 

History

History

minigraf-node

Folders and files

README.md

minigraf (Node.js)

npm License: MIT OR Apache-2.0

Embedded bi-temporal graph database for Node.js — Datalog queries, time travel, native addon

Minigraf for Node.js: a native addon (no WASM, full file I/O) with pre-built binaries for Linux x86_64/aarch64, macOS universal2, and Windows x86_64. No build step required.

Install

npm install minigraf

Quick start

import { MiniGrafDb } from 'minigraf';

// File-backed database
const db = new MiniGrafDb('myapp.graph');

// In-memory database (ephemeral / testing)
const mem = MiniGrafDb.inMemory();

// Transact facts
const r = JSON.parse(db.execute(
  '(transact [[:alice :person/name "Alice"] [:alice :person/age 30]])'
));
// { "transacted": 1 }

// Query with Datalog
const q = JSON.parse(db.execute(
  '(query [:find ?name ?age :where [?e :person/name ?name] [?e :person/age ?age]])'
));
// { "variables": ["?name", "?age"], "results": [["Alice", 30]] }

// Time travel — state as of transaction 1
const snap = JSON.parse(db.execute(
  '(query [:find ?age :as-of 1 :where [:alice :person/age ?age]])'
));

// Flush dirty pages to disk
db.checkpoint();

Response shapes

Command JSON
transact {"transacted": <tx_count>}
retract {"retracted": <tx_count>}
query {"variables": [...], "results": [[...]]}
rule {"ok": true}

Links

License

MIT OR Apache-2.0