View Source RedisGraph.Relationship (ex_redisgraph v0.1.0)

An Relationship component relating two Nodes in a Graph.

Relationships must have a source node and destination node, describing a relationship between two entities in a Graph. Nodes can be represented either as Node structures(%RedisGraph.Node{}) or id(integer) of respective node.

Relationships must have a type which identifies the type of relationship being described between entities.

Relationships, like Nodes, may also have properties, a map of values which describe attributes of the relationship between the associated Nodes.

Link to this section Summary

Functions

Compare two relationships with respect to equality.

Create a new Relationship from provided argument. Argument should be a map and key: type with value of String type is required.

Link to this section Types

@type t() :: %RedisGraph.Relationship{
  alias: atom(),
  dest_node: Node.t() | number(),
  id: integer(),
  properties: %{optional(String.t()) => any()},
  src_node: Node.t() | number(),
  type: String.t()
}

Link to this section Functions

@spec compare(t(), t()) :: boolean()

Compare two relationships with respect to equality.

Comparison logic:

  • If the ids differ, returns false
  • If the source nodes differ, returns false
  • If the destination nodes differ, returns false
  • If the types differ, returns false
  • If the properties differ, returns false
  • Otherwise returns true
@spec new(map()) :: t()

Create a new Relationship from provided argument. Argument should be a map and key: type with value of String type is required.

example

Example

alias RedisGraph.{Node, Relationship}

john = Node.new(%{
  labels: ["person"],
  properties: %{
    name: "John Doe"
  }
})

bob = Node.new(%{
  labels: ["person"],
  properties: %{
    name: "Bob Nilson"
  }
})

relationship = Relationship.new(%{
  src_node: john,
  dest_node: bob,
  type: "friend",
  properties: %{
    best_friend: true
  }
})
Link to this function

set_alias_if_nil(relationship)

View Source
@spec set_alias_if_nil(t()) :: t()