Skip to content

Instantly share code, notes, and snippets.

@bkimble
Last active August 29, 2015 14:10
Show Gist options
  • Save bkimble/eec1992851991ea2e9c8 to your computer and use it in GitHub Desktop.
Save bkimble/eec1992851991ea2e9c8 to your computer and use it in GitHub Desktop.
// Try to find a contact that is connected to a node
// with an email addrss of [email protected] or [email protected]
// Pick the first one (there should never be multiple contacts with the same emails)
// but just in case, pick the first found)
MATCH (e1:Email)-[:EMAIL]-(c1:Contact)
WHERE (e1.address IN ['[email protected]','[email protected]'])
WITH e1,c1
LIMIT 1
// Create or make user based on ID
MERGE (u:User {id: 3})
// this is the part I am not sure how to do
(IF c1 WAS NOT FOUND)
CREATE (c:Contact)
(END)
CREATE (u)-[:KNOWS]->(c)
FOREACH(email in ["[email protected]",'[email protected]'] |
MERGE (e:Email {address:email})
MERGE (c)-[:EMAIL]-(e)
)
MERGE (a:Alias {name: "Jack"})
MERGE (c)-[:ALIAS]-(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment