如何使用 Cypher 返回节点的所有属性? [英] How can I return all properties for a node using Cypher?
问题描述
我知道可以使用通配符 (*) 来返回 Cypher 查询中的所有引用,例如:
I understand it is possible to use the wildcard (*) symbol to return all references in a Cypher query, such as:
MATCH p:Product WHERE p.price='1950' RETURN *;
==> +----------------------------------------------------------------+
==> | p |
==> +----------------------------------------------------------------+
==> | Node[686]{title:"Giorgio Armani Briefcase",price:"1950",... |
==> +----------------------------------------------------------------+
然而,结果是一行带有名为p"的单个节点列",可以从中访问属性.但是,我希望结果集行"的属性名称为列".类似的东西:
However, the result is a row with a single node 'column' named "p", from which the properties can be accessed. However, I'd like the result-set 'rows' to have the property names as 'columns'. Something like:
MATCH p:Product WHERE p.price='1950' RETURN p.*;
==> +-------------------------------------------+
==> | title | price | ... |
==> +-------------------------------------------+
==> | "Giorgio Armani Briefcase" | "1950" | ... |
==> +-------------------------------------------+
该特定查询无效,但有没有办法实现相同的结果(没有明确列出所有属性,如 p.title,p.price,p... )?
That particular query isn't valid, but is there a way to achieve the same result (short of listing all the properties explicitly, as in p.title,p.price,p... )?
推荐答案
您还不能在 Cypher 中执行此操作.我认为这将是一个不错的功能,如果你想请求它.
编辑(感谢评论指出):您现在可以从 2.2 开始执行此操作:
Edit (thanks for comment pointing it out): You can now do this as of 2.2:
MATCH (p:Product) WHERE p.price='1950' RETURN keys(p);
这篇关于如何使用 Cypher 返回节点的所有属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!