struct Redis::Graph::Relationship

Overview

Represents a relationship in your graph

result = graph.read_query(<<-CYPHER)
  MATCH (:User)-[membership:MEMBER_OF]->(:Team)
  RETURN membership
CYPHER

result.each do |(membership)|
  membership = membership.as(Redis::Graph::Relationship)
  # ...
end

Defined in:

graph/relationship.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(id : Int64, type : String, src_node : Int64, dest_node : Int64, properties : Hash(String, Redis::Graph::Value)) #

[View source]

Class Method Detail

def self.matches_redis_graph_type?(type : Redis::Graph::ValueType) : Bool #

[View source]

Instance Method Detail

def dest_node : Int64 #

The node that this relationship points to, for example with (person)-[membership]->(team), it will be the node id of team.

WARNING This will not match an #id property of the destination node.


[View source]
def id : Int64 #

The identifier of the relationship.

NOTE If this relationship has an #id property, this is not that.

WARNING Do not try to query against this. RedisGraph provides no guarantees that this relationship will be at the same offset it was at the last time you queried it.


[View source]
def properties : Hash(String, Value) #

The hash of properties for this relationship.

result = graph.write_query <<-CYPHER, now: Time.utc.to_unix_ms
  CREATE (person)-[membership{since: $now}]->(team)
  RETURN membership
CYPHER
result.first.properties # => {"since" => 2022-05-15T05:48:23 UTC}

[View source]
def src_node : Int64 #

The node that this relationship originates from, for example with (person)-[membership]->(team), it will be the node id of person.

WARNING This will not match an #id property of the source node.


[View source]
def type : String #

The type of relationship, for example with [:MEMBER_OF], the #type will be "MEMBER_OF".


[View source]