我正在寻找一种方法来在 Neo4j.rb 中同时User
使用 、 和所有 sin
之间out
建立关系。both
这是我到目前为止所拥有的:
class User
include Neo4j::ActiveNode
has_many :both, :friends, type: :connection, model_class: User
has_many :out, :following, type: :connection, model_class: User
has_many :in, :followers, type: :connection, model_class: User
end
以下作品:
me = User.create
you = User.create
me.followers << you
me.followers.to_a
#=> [you]
you.following.to_a
#=> [me]
与上述相反的方法也有效。但这似乎不起作用:
me.friends << you
you.following.to_a
#=> []
或者:
me.followers.to_a
#=> []
但是,这样做:
me.following.to_a
#=> [you]