나는 다음과 같은 기본 사용 사례에 대한 neography를 사용하는 것을 시도하고있다,하지만 그것을 얻이 수없는 것 :neography를 사용하여 주어진 노드의 관계 유형과 노드를 찾는 방법은 무엇입니까?
주어진 노드에 대해- 는 나에게 해당 노드에 대한 모든 연관 관계를 말한다.
- 주어진 노드와 특정 관계에 대해 해당 관계에있는 노드를 반환 하시겠습니까? 내가 들어오는있는 관련 관계를보고 싶어,
def create_person(name) Neography::Node.create("name" => name) end johnathan = create_person('Johnathan') mark = create_person('Mark') phil = create_person('Phil') mary = create_person('Mary') luke = create_person('Luke') johnathan.both(:friends) << mark
첫째 :
https://maxdemarzi.com/2012/01/04/getting-started-with-ruby-and-neo4j/ 나는 다음 코드를 시도 :
는 여기에서 예를 따랐다.
2.2.1 :060 > johnathan.incoming.relationships
=> [{"type"=>"", "direction"=>"in"}]
내 기대 "type"=>":friends"
을 볼 수있을 것입니다하지만 난 그렇게하지 : 나는 relationships
을 시도
johnathan.incoming
=> #<Neography::NodeTraverser:0x0000000133f1c0 @from=#<Neography::Node name="Johnathan">, @order="depth first", @uniqueness="none", @relationships=[{"type"=>"", "direction"=>"in"}]>
: 내 기대는 유형 :friends
과의 관계를 보는 것입니다. 나는 다음을하려고 할 때이 관계가 무엇인지 사전에 알지 못하고 무엇인지 알고 싶어하기 때문에
하지만, 내가 할,하지만 내 사용 사례에 대해 작동하지 않습니다
2.2.1 :061 > johnathan.incoming(:friends).relationships
=> [{"type"=>"friends", "direction"=>"in"}]
두 번째 유스 케이스는 실제로 작동하는 노드를 검색하는 것입니다.
질문 : 주어진 노드와 관련된 관계 유형을 어떻게 얻을 수 있습니까?
나는 내가 그것을 알아내는 가까이라고 생각 :
johnathan.rels.map{|n| n}.first.rel_type
=> "friends"
'n1.rels.map를 {참조 | n |'은 각 관계 오브젝트를 배열로 리턴합니다. 그래서 그것은 효과가있는 것처럼 보입니다. 감사. – Angela