Getting Started

Tutorial: Building with CleaveDB

Mutual Bonds

In many social and collaborative domains, relationships are symmetric: if Jane is Pedro's teammate, Pedro is also Jane's teammate. Rather than issuing two separate statements, CleaveQL provides the AND ... AS MUTUAL clause.

Creating a bidirectional mutual bond

Connect two documents symmetrically using AND and AS MUTUAL "<label>":

CleaveQLExample · Create a mutual co-worker relationship
BOND "users:jane" AND "users:pedro" AS MUTUAL "co_worker"

CleaveDB provisions dual edges atomically in the graph layer: one from Jane to Pedro, and one from Pedro to Jane, both labeled "co_worker" in _bonds.

Querying from either direction

Traversing the bond yields the symmetric counterpart regardless of which entity anchors the query:

CleaveQLExample · Find mutual co-workers
FIND "co_worker" OF "users:jane"
FIND "co_worker" OF "users:pedro"

Both queries return the counterpart document without requiring bidirectional join tables or reverse edge indexes.