Skip to content

Instantly share code, notes, and snippets.

@nghuuquyen
Created July 23, 2018 10:19
Show Gist options
  • Save nghuuquyen/ba09fb174619f6d6ab0037302533a206 to your computer and use it in GitHub Desktop.
Save nghuuquyen/ba09fb174619f6d6ab0037302533a206 to your computer and use it in GitHub Desktop.
Sử dụng APOC để làm điều kiện
```
MATCH (user:User)
WHERE ID(user) = 611
MERGE (post:Post {description: 'test', type: 'sketch'})-[:Post {date_upload: timestamp(), visual: 0 }]->(user)
WITH user, post
OPTIONAL MATCH (gen:Genre)<-[:IT]-(gl:GenreLang)
WHERE gl.name IN ['Drammatico', 'Azione']
CALL apoc.do.when(gen IS NOT NULL, 'MERGE (post)-[:HAS_GENRE]->(gen)', '', {post: post, gen: gen}) YIELD value
WITH user, post
MATCH (post)-[:HAS_GENRE]->()<-[:IT]-(r)
RETURN user, post, r.name;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment