Last active
October 30, 2024 14:24
-
-
Save cskardon/341729d707a7e1da3653ccfd43702ec2 to your computer and use it in GitHub Desktop.
A gist of the projection queries used in the Advanced Neo4j course
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
MATCH (actor:Person)-[:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(coactor:Person) | |
WHERE actor.name = "Tom Hanks" AND actor <> coactor | |
WITH | |
actor.name AS actor, | |
m.title AS title, | |
coactor.name AS movieCoactors | |
RETURN | |
actor, title, movieCoactors | |
//002 | |
MATCH (actor:Person)-[:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(coactor:Person) | |
WHERE actor.name = "Tom Hanks" AND actor <> coactor | |
WITH | |
actor.name AS actor, | |
m.title AS title, | |
collect (coactor.name) AS movieCoactors | |
RETURN | |
actor, | |
title, | |
movieCoactors | |
//003 | |
RETURN {first: 'Tilly', last: 'Itten'} AS name | |
//004 | |
WITH {first: 'Tilly', last: 'Itten'} AS name | |
RETURN name.first + name.last AS fullname | |
//005 | |
MATCH (actor:Person)-[:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(coactor:Person) | |
WHERE actor.name = "Tom Hanks" AND actor <> coactor | |
WITH | |
actor, | |
m.title AS title, | |
collect (distinct coactor.name) AS movieCoactors | |
RETURN | |
actor, | |
{Movie: title, MovieCoactors: movieCoactors} AS projection | |
//006 | |
MATCH (actor:Person)-[:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(coactor:Person) | |
WHERE actor.name = 'Tom Hanks' AND actor <> coactor | |
WITH | |
actor.name AS actor, | |
m.title AS title, | |
collect (distinct coactor.name) AS movieCoactors | |
WITH actor, | |
{Movie: title, MovieCoactors: movieCoactors} AS projection | |
RETURN | |
actor, | |
COLLECT(projection) AS projection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment