How to determine property value type within a node in neo4j?

白昼怎懂夜的黑 提交于 2019-12-07 01:09:00

问题


Currently - there does not appear to be a way to determine if a property value in a node (or relationship) is an array/collection or a string.

match (n) where isArray(n.myprop) ....

this would be super handy when trying to understand the types of data you are working with relative to your updates and queries. Specifically, if you had situations were you were trying to update property values and needed to know "how" to update them based on how the current values were stored.


回答1:


Right now there is nothing built in but it would be a good addition. Feel free to raise an issue on github.

Something like this could help until then?

CREATE ({ a:1,b:"a",c: [1,2,3]})

MATCH (a)
RETURN size(a.a),
CASE a.a
WHEN toInt(a.a)
THEN 'int'
WHEN toFloat(a.a)
THEN 'float'
WHEN toString(a.a)
THEN 'string'
WHEN [x IN a.a | x]
THEN 'coll'
WHEN NULL THEN 'null'
ELSE 'unknown' END , size(a.b), size(a.c)


来源:https://stackoverflow.com/questions/27194534/how-to-determine-property-value-type-within-a-node-in-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!