Aries On The Cusp
Aries On The Cusp

Reputation: 419

No documentation on how to use neo4j pipe | in foreach

Does anyone know where the documentation is for the pipe operator (ie: | ) in Neo4j ? I saw this code snippet below on StackOverflow and have searched Neo4j's documentation but have yet to find it.

I'm assuming it's used as a continuation but I'd love to see the docs or get an explanation of how to use it

(game in {PSNGames} | 
                MERGE p-[:PLAYS {LastPlayed : game.LastUpdated}]->(g:PSNGame {NPCOMMID : game.NPCOMMID})-[:LOCALE]->(l:PSNGameLocalized {NPCOMMID : game.NPCOMMID}) 
                SET g = game, 
                    l = { NPCOMMID : game.NPCOMMID, 
                         TitleName : game.TitleName, 
                       TitleDetail : game.TitleDetail, 
                            Locale : {locale} 
                        })

Upvotes: 1

Views: 990

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39925

You can use the pipe e.g. when constructing a collection based on another collection, aka list comprehension. E.g. extract a property from all nodes along a path:

MATCH path=(me:Person {name:'myself'})-[:KNOWS*..5]-(other)
RETURN [x in nodes(path) | x.name ]

FOREACH uses the pipe in the same way, see http://neo4j.com/docs/stable/query-foreach.html.

Upvotes: 2

Related Questions