考虑这个简单的设置:
class Person
include Neo4j::ActiveNode
property :name, type: String
has_many :out, :follows, model_class: Person, rel_class: Friendship
has_many :in, :followed_by, model_class: Person, rel_class: Friendship
end
class Friendship
include Neo4j::ActiveRel
property :key, type: String
type 'friendship'
from_class Person
to_class Person
end
我将如何在所有Friendship
s 中搜索匹配条件的那些?(例如Friendship
某个键的 s)。
在一封电子邮件中,Brian Underwood 向我指出了这个片段:
ModelClass.association_name(:node_var, :rel_var).where("rel_var = 'some_condition'")
我试过玩弄它,但不明白。是ModelClass
一个ActiveNode
还是ActiveRel
实例?什么是:node_var
和:rel_var
?