View Source RedisGraph.Util (ex_redisgraph v0.1.0)

Provides utility functions for RedisGraph modules.

Link to this section Summary

Functions

Converts labels list into string representation. Otherwise returns empty string.

Converts properties map into string representation. Otherwise returns empty string.

Generate a random string of characters a-z of length n.

Converts labels list into string representation. Otherwise returns empty string.

Converts received value into string representation.

Link to this section Functions

Link to this function

labels_to_string(labels)

View Source
@spec labels_to_string([String.t()] | any()) :: String.t()

Converts labels list into string representation. Otherwise returns empty string.

This is used to serialize RedisGraph.Node labels into strings when preparing redisgraph queries.

example

Example

alias RedisGraph.{Node, Util}

bob = Node.new(%{
  alias: :n,
  labels: ["person", "student"],
  properties: %{
    name: "Bob Thomsen",
    age: 22
  }
})

bob_labels = Util.labels_to_string(bob.labels)
Link to this function

properties_to_string(properties)

View Source
@spec properties_to_string(map() | any()) :: String.t()

Converts properties map into string representation. Otherwise returns empty string.

This is used to serialize edisGraph.Node or RedisGraph.Relationship properties into strings when preparing redisgraph queries.

example

Example

alias RedisGraph.{Node, Util}

bob = Node.new(%{
  alias: :n,
  labels: ["person"],
  properties: %{
    name: "Bob Thomsen",
    age: 22
  }
})

bob_properties = Util.properties_to_string(bob.properties)
@spec random_string(pos_integer()) :: String.t()

Generate a random string of characters a-z of length n.

This is used to create a random alias for a node or relationship if one is not already set.

@spec type_to_string([String.t()] | any()) :: String.t()

Converts labels list into string representation. Otherwise returns empty string.

This is used to serialize RedisGraph.Node labels into strings when preparing redisgraph queries.

example

Example

alias RedisGraph.{Relationship, Util}

relationship = Relationship.new(%{
  src_node: 1,
  dest_node: 2,
  type: "friend",
  properties: %{
    best_friend: true
  }
})
relationship_type = Util.type_to_string(relationship.type)
@spec value_to_string(any()) :: String.t()

Converts received value into string representation.

This is used to serialize value into strings when preparing redisgraph queries.

example

Example

alias RedisGraph.{Node, Util}

list_to_string = Util.value_to_string(["test", 11, 12.12, false, nil, ["hi", "bye"], %{me: "you"}])