keys
returns a list containing the string representations for all the property names of a node, relationship, or map.
Syntax:keys(expression)
Returns: A list containing String elements.
Arguments
Name | Description |
expression | An expression that returns a node, a relationship, or a map. |
Example
MATCH (a:Person {name:"Elon"})
RETURN keys(a)
The value returned will be a list of all the property names of the node a
as a string representation. For example, in this case, the result might look like-
["name","date_of_birth","age", "profession"]
Considerations
keys(null)
returnsnull
.
Example
CREATE (a:Person {name:"foo", country:"India"})-[:KNOWS]->(:Person {name:"bar"})
RETURN keys(a)
Returns the following Result
keys(a) |
["name", "country"] |
Example
CREATE (a:Person {name:"foo", country:"India"})-[:KNOWS]->(:Person {name:"bar"})
RETURN keys(a)
Returns the following Result
keys(a) |
["name", "country"] |
Example
CREATE (a:Person)
RETURN keys(a)
Returns the following Result
keys(a) |
[] |
Example
CREATE (:Person {name:"foo", country:"India"})-[b:KNOWS]->(:Person {name:"bar"})
RETURN keys(b)
Returns the following Result
keys(b) |
[] |
Example
CREATE (:Person {name:”Elon”, country:”USA”})-[b:FOUNDER_OF {founded_in:2002}]->(:Company {name:”SpaceX”})
RETURN keys(b)
Returns the following Result
keys(a) |
["founder_of"] |
Example
RETURN keys({key1:"value1", key2:"value2", key3:"value3"})
Returns the following Result
keys({key1:"value1", key2:"value2", key3:"value3"}) |
["key1", "key2", "key3"] |
Note–keys()
function can be used with Map too.
Example
RETURN keys(null)
Returns the following Result
keys(null) |
null |
Note–keys(null)
returns null
.