8000 GitHub - project-minigraf/minigraf-node at v2.x · GitHub
[go: up one dir, main page]

Skip to content

About

Node.js bindings for Minigraf — bi-temporal graph database

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

minigraf (Node.js)

Node.js binding for Minigraf, an embedded graph database. Open an in-memory database or a local file without running a separate server. Use bi-temporal Datalog queries to ask when a fact applied and when the database recorded it.

Installation

npm install minigraf
Platform Architecture Support
Linux x64 ✅
Linux arm64 ✅
macOS universal (x64 + arm64) ✅
Windows x64 ✅

Requires Node.js 18+.

Quick start

import { MiniGrafDb } from 'min
7A74
igraf'

// In-memory database
const db = MiniGrafDb.inMemory()
db.execute('(transact [[:alice :name "Alice"] [:alice :age 30]])')

const result = JSON.parse(db.execute('(query [:find ?n :where [?e :name ?n]])'))
console.log(result.results[0][0])  // "Alice"

// File-backed (persisted to disk)
const db2 = new MiniGrafDb('path/to/mydb.graph')
db2.execute('(transact [[:bob :name "Bob"]])')
db2.checkpoint()
db2.close()

Closing a file-backed database

Only one handle per .graph file may be open in a process at a time — two would each cache their own page table and corrupt the file — so call close() when you are done with one:

const db = new MiniGrafDb('mydb.graph')
db.execute('(transact [[:bob :name "Bob"]])')
db.checkpoint()
db.close()

const again = new MiniGrafDb('mydb.graph') // fine: the first handle is gone

Call close() before reopening the same file. Dropping the last reference does not release the handle: V8 may collect the object much later, or not at all before the process exits. Reopening before collection throws Database is already open in this process.

close() is idempotent; every other method throws once it has run. In-memory databases hold no file lock, so closing them is optional.

Building from source

Requires Rust stable toolchain and @napi-rs/cli.

npm install
npx napi build --platform --release --no-js

Cascade release

The core release cascade sends a core-release event. The Node release workflow on main selects v2.x for 2.x releases. It pins the matching core crate, builds and tests the native packages, then commits, tags, and publishes the tested packages. See the release workflow notes on main for retries and rehearsals.

License

MIT OR Apache-2.0

About

Node.js bindings for Minigraf — bi-temporal graph database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0