View Source RedisGraph.Node (ex_redisgraph v0.1.0)

A Node member of a Graph.

Nodes have an alias which uniquely identifies them in a Graph. Nodes must have an alias. When alias is not provided on initialization, a random alias will be set on the Node.

Nodes may optionally have a list of labels which is analogous to a type definition. Nodes can be queried based on their labels, e.g. person or place or food.

Nodes may optionally have properties as well, which is a map of values associated with the entity. These properties can be returned by database queries.

Nodes which are created as the result of a passed query to the graph database through RedisGraph.QueryResult will also have numeric ids which are internal to the graph in the database.

Link to this section Summary

Functions

Compare two Nodes with respect to equality.

Creates a new Node with default arguments.

Creates a new Node from provided argument.

Sets the node's alias to atom if it is nil.

Link to this section Types

@type t() :: %RedisGraph.Node{
  alias: atom(),
  id: integer(),
  labels: [String.t()],
  properties: %{}
}

Link to this section Functions

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

Compare two Nodes with respect to equality.

Comparison logic:

  • if ids differ then returns false
  • if aliases differ then returns false
  • if labels differ then returns false
  • if properties differ then returns false
  • otherwise returns true
@spec new() :: t()

Creates a new Node with default arguments.

example

Example

alias RedisGraph.{Node}

# create a Node
bob = Node.new()
@spec new(map()) :: t()

Creates a new Node from provided argument.

example

Example

alias RedisGraph.{Node}

# create a Node
bob = Node.new(%{
  alias: :n,
  labels: ["person"],
  properties: %{
    name: "Bob Thomsen",
    age: 22
  }
})
@spec set_alias_if_nil(t()) :: t()

Sets the node's alias to atom if it is nil.