Created
April 25, 2016 15:26
-
-
Save apcj/3851e64d5dae640ac4f2bb6123b56488 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MERGE (person:Person{name:"Alistair"}) | |
MERGE (role:Role{name:"Software Engineer"}) | |
MERGE (company:Company{name:"Neo Technology"}) | |
CREATE (empl:Employment{from: 2011}) | |
MERGE (person)-[:CURRENT]->(empl) | |
MERGE (empl)-[:WORKS_AT]->(company) | |
MERGE (empl)-[:ROLE]->(role) | |
// Determine whether first story already exists | |
WITH empl, person, | |
CASE WHEN ((person)-[:FIRST]->()) THEN [] ELSE ["blalba"] | |
END | |
AS firstNotExists | |
// Create FIRST rel newStory is first story | |
FOREACH (i IN firstNotExists | MERGE (person)-[:FIRST]->(empl)) | |
WITH empl, person | |
// Delete old LAST relationship | |
MATCH (empl)<-[:CURRENT]-(person)-[oldCurrent:CURRENT]->(oldEmployment) | |
DELETE oldCurrent | |
MERGE (oldEmployment)-[:NEXT]->(empl) | |
SET oldEmployment.to = empl.from; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment