harshvardhan
harshvardhan

Reputation: 805

Read a property of a node in neo4j

How can I read a property of a node in neo4j? For example I have a node called 'mug' of the type 'crockery' and color 'brown' which I created as

create (mug:crockery{category:'mug', color:'brown'})
return mug

This will create a node.

Suppose this node was created programmatically through a script or service. How can I read the property 'color' of this node?

Upvotes: 0

Views: 46

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30397

You should probably review the developer manual and maybe review some tutorials online.

You would need to match to the node in question and then return its color property. If category is unique to a :crockery node, then it would be enough to look up the node by its category and then return its color, like so:

match (n:crocker)
where n.category = 'mug'
return n.color

Note that I used n rather than mug here. The mug variable you used in your create query, like all variables, is never saved to the database, and is only present as a reference to a node (or nodes) and only persists at most until the end of the query.

Upvotes: 1

Related Questions