properties()
returns a map containing all the properties of a node or relationship. If the argument is already a map, it is returned unchanged.
Syntax: properties(expression)
Returns: A Map.
Arguments
Name | Description |
expression | An expression that returns a node, a relationship, or a map. |
Example
MATCH (a:Person {name:"Carl"})
RETURN properties(a)
The value returned will be the a map which contains all the properties of the node with the label Person and a value of Carl for the property name. For example, the result might look like-
{
"name":"Carl",
"lastname":"Sagan",
profession:"Astronomer"
}
Example
MATCH (:Person {name:"Carl"})-[b:KNOWS]->(:Person {name:"Neil"})
RETURN properties(b)
The value returned will be the a map which contains all the properties of the relationship between the nodes with label Person which has name Carl, and with the label Person and name Neil. For example, the result might look like-
{
"from":1994,
"venue":"Conference"
}
Considerations
properties(null)
returnsnull
.
Example
CREATE (:Person {name:"foo"})-[b:KNOWS]->(:Person {name:"bar"})
RETURN properties(b)
Returns the following Result
properties(b) |
{ } |
Note-Since the relationship does not contain any properties, an empty map is returned.
Example
CREATE (a:Person)
RETURN properties(a)
Returns the following Result
properties(a) |
{ } |
Note-Since the node does not contain any properties, an empty map is returned.
Example
CREATE (a:Company {name:"SpaceX", founder:"Elon Musk", founded:2002})
RETURN properties(a)
Returns the following Result
properties(a) |
{ "founder": "Elon Musk", "name": "SpaceX", "founded": 2002 } |
Example
CREATE (:Person {name:"Elon Musk"})-[b:FOUNDED {year:2002, venue:"California"}]->(:Company {name:"SpaceX"})
RETURN properties(a)
Returns the following Result
properties(b) |
{ "venue": "California", "year": 2002 } |
Example
RETURN properties({name:"Elon Musk", profession:"Entrepreneur", nationality:"American"})
Returns the following Result
properties({name:"Elon Musk", profession:"Entrepreneur", nationality:"American"}) |
{ name:"Elon Musk", profession:"Entrepreneur", nationality:"American" } |
Note– Passing a Map to the property function returns the Map unchanged.
Example
RETURN properties(null)
Returns the following Result
properties(null) |
null |