【问题标题】:Method "rel_length" in Neo4j.rb doesn't work.Neo4j.rb 中的方法“rel_length”不起作用。
【发布时间】:2023-03-07 12:06:02
【问题描述】:

我需要得到User 的“朋友的朋友”。所以,friend(rel_length: 2) 不起作用(忽略方法),返回朋友。

class User
  include Neo4j::ActiveNode
  ...
  has_many :out, :friend, rel_class: Friend
  ...
end

class Friend
  include Neo4j::ActiveRel
  from_class User
  to_class User
  type 'friend'

  property :activity, type: String
  property :relation, type: String
  property :token, type: String
end

【问题讨论】:

  • 请完善题名。
  • 你能分享一下你尝试调用friend(rel_length: 2)时生成的Cypher吗?您可能需要在末尾添加 to_a 或以其他方式枚举它
  • fr=user.friend(rel_length:2) 结果是:"friend]->({:rel_length=>2}:User)"[0m>>..." fr=user.friend(rel_length:2).to_a 结果是:“RETURN 的参数无效。完整参数:{:rel_length=>2} | 无效部分:2”
  • 您使用的是哪个版本的 neo4jneo4j-core gem? rel_length 是在 5.1.0 版本中引入的,我相信
  • 确实,问题出在 gems 的版本上。非常感谢。

标签: ruby-on-rails neo4j social-networking neo4j.rb


【解决方案1】:

对于后来发现此问题的任何人来说,原因是因为他使用的是旧版本的 gem(请参阅 cmets)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多