Kailash
(Kailash)
July 5, 2019, 7:30am
1
Team, is there any way to get all the property in a node/Label and data type of all of those?
I am trying below query, but apoc.meta.type(property) gives as STRING Always for all property
call apoc.meta.data() yield label, property
with ['company'] as labels, property, label where label in labels
return property, label , apoc.meta.type(property)
paulare
(Paul Are)
December 9, 2019, 8:31pm
2
Hi, @Kailash
Are looking for something like:
MATCH (p:Person {name: 'Eve'})
WITH p
RETURN apoc.meta.cypher.types(p)
{
"name": "STRING",
"gender": "STRING",
"age": "INTEGER",
"kids": "INTEGER"
}
To get same result, each line separate:
MATCH (p)
WITH distinct p, keys(p) as pKeys
UNWIND pKeys as Key
RETURN distinct labels(p), Key, apoc.map.get(apoc.meta.cypher.types(p), Key, [true])
Result
βββββββββββββ€ββββββββββ€βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β"labels(p)"β"Key" β"apoc.map.get(apoc.meta.cypher.types(p), Key, [true])"β
βββββββββββββͺββββββββββͺβββββββββββββββββββββββββββββββββββββββββββββββββββββββ‘
β["Person"] β"age" β"INTEGER" β
βββββββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β["Person"] β"kids" β"INTEGER" β
βββββββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β["Person"] β"name" β"STRING" β
βββββββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β["Person"] β"gender" β"STRING" β
βββββββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β["Forum"] β"name" β"STRING" β
βββββββββββββΌββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β["Forum"] β"members"β"INTEGER" β
βββββββββββββ΄ββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Same thing for relationships:
MATCH ()-[p]-()
WITH distinct p, keys(p) as pKeys
UNWIND pKeys as Key
RETURN distinct type(p), Key, apoc.map.get(apoc.meta.cypher.types(p), Key, [true])
Result
βββββββββββ€ββββββββ€βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β"type(p)"β"Key" β"apoc.map.get(apoc.meta.cypher.types(p), Key, [true])"β
βββββββββββͺββββββββͺβββββββββββββββββββββββββββββββββββββββββββββββββββββββ‘
β"KNOWS" β"since"β"INTEGER" β
βββββββββββ΄ββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββ