Neo4j.rb忽略返回neoId的id属性

时间:2022-09-04 18:01:27

I am trying to add id property to my node. Its value is properly saved to neo4j database, which i can confirm with webadmin app. But if I later try to access it or serialize to json this property is set with the value of neoId.

我正在尝试将id属性添加到我的节点。它的值被正确保存到neo4j数据库,我可以用webadmin app确认。但是如果我稍后尝试访问它或序列化为json,则使用neoId的值设置此属性。

I would really need this property and I've read before that I shouldn't use neoId as a way to identify objects.

我真的需要这个属性,之前我已经读过,我不应该使用neoId作为识别对象的方法。

Do you have any idea how to get desired effect?

你知道如何获得理想的效果吗?

I should have mentioned that I am using Neo4j.rb with Rails.

我应该提到我正在使用Neo4j.rb和Rails。

1 个解决方案

#1


3  

You shouldn't set the id as a new property. Nodes and relationships always have an identifier property by design. Its value is automatically generated by Neo4j. If you want your own kind of identifier, you can't name it "id".

您不应将id设置为新属性。节点和关系始终具有设计的标识符属性。它的值由Neo4j自动生成。如果您需要自己的标识符,则不能将其命名为“id”。

#1


3  

You shouldn't set the id as a new property. Nodes and relationships always have an identifier property by design. Its value is automatically generated by Neo4j. If you want your own kind of identifier, you can't name it "id".

您不应将id设置为新属性。节点和关系始终具有设计的标识符属性。它的值由Neo4j自动生成。如果您需要自己的标识符,则不能将其命名为“id”。