Expand description
Zero-config, single-file, embedded graph database with bi-temporal Datalog queries.
Minigraf is the SQLite of graph databases: embedded, no server, no configuration,
a single portable .graph file. It stores data as Entity-Attribute-Value facts,
queries them with Datalog, and tracks every
change with full bi-temporal history (transaction time + valid time).
§Installation
[dependencies]
minigraf = "0.21"§Quick Start
use minigraf::{Minigraf, BindValue};
// Open (or create) a database
let db = Minigraf::in_memory().unwrap();
// Assert facts
db.execute(r#"(transact [[:alice :person/name "Alice"]
[:alice :person/age 30]
[:alice :friend :bob]
[:bob :person/name "Bob"]])"#).unwrap();
// Query with Datalog
let results = db.execute(r#"
(query [:find ?friend-name
:where [:alice :friend ?friend]
[?friend :person/name ?friend-name]])
"#).unwrap();
// Explicit transaction — all-or-nothing
let mut tx = db.begin_write().unwrap();
tx.execute(r#"(transact [[:alice :person/age 31]])"#).unwrap();
tx.commit().unwrap();
// Time travel — query the state as of transaction 1
db.execute("(query [:find ?age :as-of 1 :where [:alice :person/age ?age]])").unwrap();§Feature Flags
| Feature | Target | Description |
|---|---|---|
| (default) | native / WASI | File-backed and in-memory databases; full Datalog engine |
browser | wasm32-unknown-unknown | Enables the browser module (BrowserDb), backed by IndexedDB for use inside a web browser via wasm-pack |
The browser feature is only meaningful on the wasm32-unknown-unknown target.
When browsing docs on docs.rs, switch the target to
wasm32-unknown-unknown (top-right target selector) to see the full browser API.
§WebAssembly targets
- Browser (
wasm32-unknown-unknown+browserfeature) —wasm-pack build --target web --features browser - WASI / server-side (
wasm32-wasip1) —cargo build --target wasm32-wasip1 --release --bin minigraf
Re-exports§
pub use db::OpenOptionsWithPath;Non-WebAssembly pub use db::Minigraf;pub use db::OpenOptions;pub use db::WriteTransaction;pub use repl::Repl;
Modules§
- db
- Public
Minigraffacade withWriteTransactionandOpenOptions. - repl
- Interactive REPL for exploring a
Minigrafdatabase from the command line.
Structs§
- Prepared
Query - A parsed and validated query template with named bind slots (
$name).
Enums§
- AsOf
- A point-in-time selector for transaction-time travel queries.
- Bind
Value - A concrete value supplied to a named bind slot (
$name) in aPreparedQuery. - Query
Result - The result of executing a Datalog command via
crate::db::Minigraf::execute. - ValidAt
- A point-in-time selector for valid-time queries.
- Value
- All value types that can be stored in a Minigraf fact.
Type Aliases§
- Entity
Id - A unique identifier for a graph entity (UUID v4).