Graph Model

ArcFlow stores data as a property graph — nodes connected by relationships, each carrying key-value properties.

Nodes#

Nodes represent entities. Each node has:

  • Labels — categories like :Person, :Company, :Fact (a node can have one label)
  • Properties — key-value pairs like {name: 'Alice', age: 30}
db.mutate("CREATE (n:Person {name: 'Alice', age: 30, email: 'alice@example.com'})")

Relationships#

Relationships connect two nodes with a direction and type:

// Alice works at Acme
db.mutate("MATCH (a:Person {name: 'Alice'}) MATCH (c:Company {name: 'Acme'}) MERGE (a)-[:WORKS_AT]->(c)")

Relationships can also carry properties:

db.mutate("MATCH (a:Person {name: 'Alice'}) MATCH (b:Person {name: 'Bob'}) MERGE (a)-[:KNOWS {since: 2020}]->(b)")

Properties#

Property values can be:

TypeExampleWorldCypher Literal
String'Alice''Alice'
Integer3030
Float3.143.14
Booleantruetrue / false
List (string)['a','b']'a,b' (comma-separated)

Querying the graph#

Pattern matching is how you read the graph. You describe the shape you're looking for:

// Find all people
db.query("MATCH (n:Person) RETURN n.name, n.age")
 
// Find who works where
db.query("MATCH (p:Person)-[:WORKS_AT]->(c:Company) RETURN p.name, c.name")
 
// Traverse 1-3 hops
db.query("MATCH (a:Person {name: 'Alice'})-[:KNOWS*1..3]->(b) RETURN b.name")

Schema-optional#

ArcFlow doesn't require a schema upfront. Create any node with any properties at any time. Use CALL db.schema() to inspect the emergent schema:

const schema = db.query("CALL db.schema()")
// Shows which labels exist and what properties they carry

In-memory vs. persistent#

import { open, openInMemory } from '@ozinc/arcflow'
 
// In-memory: fast, ephemeral, great for tests
const mem = openInMemory()
 
// Persistent: WAL-journaled, survives restarts
const disk = open('./data/graph')

See Also#

Try it
Open ↗
Loading engine…