Skip to main content

write_cypher

Function write_cypher 

Source
pub fn write_cypher(
    source: &dyn ExportSource,
    dest: &Path,
) -> Result<(ExportStats, CypherLoss), CliError>
Expand description

Write graph.cypher to dest: one statement per line, no terminator, the way mushroomdb query --file and --stdin take one. Nodes first, then manual edges.

MERGE (n:`Person` {id: 'alice'}) ON CREATE SET n.`age` = 30, n.`tags` = ['a', 'b']
MERGE (a:`Person` {id: 'alice'})-[:`KNOWS`]->(b:`Person` {id: 'bob'})

MERGE rather than CREATE, so that running the file twice is harmless. Cypher stores the key of a node as its id property, so a node whose properties had no id gains one (CypherLoss::ids_added counts them): the file reproduces the store exactly when every node’s id equals its key (what mushroomdb import and ingest produce). Rules are not written: Cypher has no statement for one.