Graph-Document Sync

Define sync rules to automatically keep graph nodes and document collections in sync. Changes propagate bidirectionally within the same transaction.

SYNC LABEL ... TO COLLECTION

-- Sync Person nodes to a persons collection, keyed by name
SYNC LABEL Person TO COLLECTION persons KEY name INCLUDE name, email, age

-- Sync all properties (omit INCLUDE)
SYNC LABEL Product TO COLLECTION products KEY sku

-- With SKIP TRIGGERS to prevent cascades
SYNC LABEL User TO COLLECTION user_cache KEY username INCLUDE username, role SKIP TRIGGERS

Now creating a :Person node auto-creates a document in persons, and vice versa. The KEY property on the node becomes the document key.

Sync Directions

DirectionDescription
Bidirectional (default)Changes in either model propagate to the other
Graph-to-DocumentOnly graph writes create/update documents
Document-to-GraphOnly document writes create/update nodes

Conflict Resolution

StrategyDescription
Last-Write-Wins (default)Most recent write takes precedence
Graph-WinsGraph data always takes precedence on conflict
Document-WinsDocument data always takes precedence on conflict

Management

-- List all sync rules
SHOW SYNC RULES

-- Drop a sync rule by ID
DROP SYNC RULE 1