Cypher startNode Function

startNode() returns the end node of a relationship.

Syntax: startNode(relationship)

Returns: A Node.

Arguments

NameDescription
relationshipA numeric expression.

Example

CREATE (:Person {name:"Elon Musk"})-[b:FATHER_OF]->(:Person {name:"X Æ A-12 Musk"})
RETURN startNode(b)

The value returned will be start-node of the relationship b. Which in this case will be-

{
"name": "Elon Musk"
}

Considerations

  • startNode(null) returns null.

Example

CREATE (:Person {name:"Elon Musk"})-[b:OWNS]->(:Company {name:"SpaceX"})
RETURN startNode(b)

Returns the following Result

startNode(b)
{
"name": "Elon Musk"
}

Example

CREATE (:Person {name:"Elon Musk", birthplace:"South Africa", profession:"Entrepreneur"})-[b:OWNS]->(:Company {name:"SpaceX"})
RETURN startNode(b)

Returns the following Result

startNode(b)
{
"name": "Elon Musk",
"birthplace": "South Africa",
"venue": "Entrepreneur"
}

Example

CREATE (:Person)-[b:OWNS]->(:Company {name:"SpaceX"})
RETURN startNode(b)

Returns the following Result

startNode(b)
{

}

Note– The end-node for the relationship b does not have any properties, and for that reason an empty map(representing a node) is returned.

Example

MATCH(:Person)-[b:OWNS]->(:Company {name:"SpaceX"})
RETURN startNode(b)

This query is similar to the query above it, just that it searches for existing patterns in the databases instead of creating them. This query returns the following result, similar to the above query.

startNode(b)
{

}

Example

RETURN startNode(null)

Returns the following Result

startNode(null)
null

Learn More