I'm trying to write a Cypher query that will return the data type of all properties in a given entity in a Neo4j database. For example, given the following node:
CREATE (:Person { name: 'Alice', age: 35, active: true })
I'd like to write a query that returns something like this:
name: string
age: integer
active: boolean
Is there a way to do this in Cypher?
You can use apoc.meta.type
, to get the datatype of a property like this:
CREATE (p:Person { name: 'Alice', age: 35, active: true })
WITH keys(properties(p)) as keys, properties(p) AS propertyMap
UNWIND keys AS key
RETURN key, apoc.meta.type(propertyMap[key])
And like this:
CREATE (p:Person { name: 'Alice', age: 35, active: true })
RETURN apoc.meta.types(properties(p))