Getting Started

Tutorial: Building with CleaveDB

Document & URL Links (LINK)

While BOND creates semantic, weighted, and lifecycle-managed graph relationships, LINK is CleaveDB's lightweight mechanism for direct structural document references and external web resource links. Links are stored in the dedicated _links collection.

Unlabelled document links

Unlike BOND, a relationship label is optional on LINK. If omitted, the label automatically defaults to "linked":

CleaveQLExample · Direct document link
LINK "users:jane" TO "users:juan"

You can also supply an optional custom label when desired: LINK "users:jane" TO "users:juan" AS "mentor".

External URL references

LINK uniquely supports external HTTP and HTTPS URLs as targets, enabling documents to reference remote API endpoints, GitHub profiles, or web resources:

CleaveQLExample · Link to external web resource
LINK "users:jane" TO "https://github.com/jane"

External URLs are validated as syntactically correct URLs and are exempt from local bucket existence checks.

Inspecting and finding links

Query all links in the database or inspect outgoing links from a specific document:

CleaveQLExample · Inspect links
-- List all document and URL links in the database
SHOW LINKS

-- Show all links originating from Jane
FIND LINKS OF "users:jane"

This returns link records from _links showing target IDs or URLs.

Removing links with UNLINK

Links are removed using the UNLINK command:

CleaveQLExample · Remove links
-- Unlink two documents
UNLINK "users:jane" FROM "users:juan"

-- Unlink an external URL
UNLINK "users:jane" FROM "https://github.com/jane"