Getting Started

Tutorial: Building with CleaveDB

Following a Bond

Documents can be connected by named, directed relationships called bonds. A bond lookup starts from a document the application already knows, follows one label, and returns the connected document. It is a direct way to answer a question such as “Who manages John?” without making the application inspect relationship records and then issue a second lookup itself.

Name the relationship and its source

Put the bond label after FIND and give its source document as a bucket-and-ID address. In the example, employees:john is the source and manager is the connection CleaveDB should follow.

CleaveQLExample · Retrieve John’s manager
FIND "manager" OF "employees:john"

A relationship query is most useful when the starting document is already known and the application wants the document or documents on the other side of one named bond. It keeps the relationship in the database’s graph model rather than asking application code to reconstruct it from hidden storage details.

What CleaveDB does with the lookup

Bonds are kept in CleaveDB’s internal _bonds collection with source, target, and label information. For a direct lookup, the engine matches the source address and label, obtains the target document ID, and retrieves that target document. The relationship record is an implementation detail; your query can stay focused on the source and the connection you mean.