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
| Direction | Description |
|---|---|
| Bidirectional (default) | Changes in either model propagate to the other |
| Graph-to-Document | Only graph writes create/update documents |
| Document-to-Graph | Only document writes create/update nodes |
Conflict Resolution
| Strategy | Description |
|---|---|
| Last-Write-Wins (default) | Most recent write takes precedence |
| Graph-Wins | Graph data always takes precedence on conflict |
| Document-Wins | Document data always takes precedence on conflict |
Management
-- List all sync rules SHOW SYNC RULES -- Drop a sync rule by ID DROP SYNC RULE 1