You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

cypher()

Usage

cypher(query, parameterMap)
cypher(query)

Description
Executes the given Cypher query and returns the results. Structr will automatically convert all query results into the corresponding Structr objects, i.e. Neo4j nodes will be instantiated to Structr node entities, Neo4j relationships will be instantiated to Structr relationship entities, and maps will converted into Structr maps that can be accessed using the dot notation (map.entry.subentry).

Note
The cypher() function always returns a collection of objects, even if LIMIT 1 is specified!

Example

${cypher('MATCH (n:User) RETURN n')}

results in

[7379af469cd645aebe1a3f8d52b105bd, a05c044697d648aefe3ae4589af305bd, 505d0d469cd645aebe1a3f8d52b105bd]

Example using Parameters

${{
    var query = "MATCH (user:User) WHERE user.name = { userName } RETURN user";
    var users = Structr.cypher(query, {userName: 'admin'});
}}

Search results for "cypher()"

cypher()

Executes the given Cypher query and returns the results. Structr will automatically convert all query results into the corresponding Structr objects, i.e. Neo4j nodes will be instantiated to Structr node entities, Neo4j relationships will be instantiated to Structr relationship entities, and maps will converted into Structr maps that can be accessed using the dot notation (map.entry.subentry).

cypher(query [, key1, value1 [, ... ]] )
cypher(query [, map] )

Advanced examples

If you are evaluating request parameters inside a cypher repeater there is a risk of cypher injection as the parameters can only be used inline. A better solution would be to use a function query repeater with the cypher() function and real parameters.