0

I have a node Country. I know that this node has some properties, but I don't know which. I mean, I know since I've take a look at model. Here is what I've found in documentation:

Country
name: String
iso_2_code: String 
iso_3_code: String 
region: String 
sub.region: String

I know that if I run

MATCH (c:Country)
RETURN c.iso_2_code

I'll get result for one specific property. Is there a query that would as a result return me something like: name, iso_2_code, iso_3_code, region, sub.region?

If I didn't have access to the model how could I list all of the properties that are attached to some node type?

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
GiteNator
  • 25
  • 6

1 Answers1

0

Answering more from a Cypher or openCypher perspective than for a specific implementation. Using the air-routes dataset. There are three things to consider.

Firstly if you know the properties you want, as you mentioned, you can just ask for them explicitly.

MATCH (a:airport {icao:'KDFW'})
RETURN a.city, a.desc

However, if you want all properties, but do not want to list them all, you can just do:

MATCH (a:airport {icao:'KDFW'})
RETURN properties(a)

If you just want the property keys:

MATCH (a:airport {icao:'KDFW'})
RETURN keys(properties(a))

Lastly, if you want the properties plus the label and ID information you can just do:

MATCH (a:airport {icao:'KDFW'})
RETURN a
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
  • Thanks! This are all useful thing for me since I'm new to Cypher. keys () is the thing that I was looking for! – GiteNator Jan 26 '23 at 07:38