0
Neo4jクラスのインスタンスからそのクラスの別のインスタンスに関係を作成する適切な方法は何ですか?Neo4jの自己関係
たとえば、他のコースに先行するコースのモデルを使用して、コースカタログのコースをモデリングしているとします。
私はレールとのNeo4j使用しています:
モデル:
クラスコース<のNeo4j :: Railsの::モデルのプロパティ:(:PREREQS).from(コース、:leadstos
has_nに名前を)has_n(:leadstos)
オブジェクトと関係の作成:
algebra = Course.create :name => 'algebra'
arithmetic = Course.create :name => 'arithmetic'
algebra.prereqs << arithmetic
algebra.save!
arithmetic.save!
algebra.prereqs.each {|node| puts node [:name]}
#prints 'arithmetic'
を
ただし、arithmetic.leadstos.each {|node| puts node[:name]}
は空白になります。