struct Redis::Graph::Client(Runnable)

Defined in:

graph.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(redis : Runnable, key : String) #

[View source]

Instance Method Detail

def multi(&) #

Execute a transaction within the given graph

graph.multi do |txn|
  txn.write_query <<-CYPHER, team_id: 123
    MATCH (
  CYPHER
end

EXPERIMENTAL This method may be difficult to use, since it relies primarily on Redis::Client#multi, which is not graph-aware. It is currently intended primarily to roll back previous writes if others do not succeed when a single query is not feasible. This may be iterated on in the future.


[View source]
def read_query(cypher : String, params : NamedTuple | Hash, return types : Tuple(*T)) forall T #

Query the graph with the given Cypher query, passing in the given params, and returning the given types corresponding to the values in your Cypher RETURN clause.

graph.read_query <<-CYPHER, {team_id: 123}, return: {Person}
  MATCH (team:Team{id: $team_id})
  MATCH (person)-[:MEMBER_OF]->(team)
  RETURN person
CYPHER

[View source]
def read_query(cypher : String, params : NamedTuple | Hash, return type : T.class) forall T #

[View source]
def read_query(cypher : String, return types : Tuple(*T)) forall T #

[View source]
def read_query(cypher : String) #

Query the graph with the given Cypher query.

graph.read_query <<-CYPHER
  MATCH (person:Person)
  RETURN person
CYPHER

[View source]
def read_query(cypher : String, **params) #

Query the graph with the given Cypher query, passing in the given params.

graph.read_query <<-CYPHER, team_id: 123
  MATCH (team:Team{id: $team_id})
  MATCH (person)-[membership:MEMBER_OF]->(team)
  RETURN person, membership, team
CYPHER

[View source]
def write_query(cypher : String, params : NamedTuple | Hash, return types : Tuple(*T)) forall T #

Write data to the graph using the given cypher query, passing in the given params and returning the given types for the values in your query's RETURN clause.

graph.write_query <<-CYPHER, {id: 123, now: Time.utc.to_unix_ms}, return: {Person}
  MATCH (person:Person{id: $id})
  SET person.confirmed_at = $now
  RETURN person
CYPHER

[View source]
def write_query(cypher : String, params : NamedTuple | Hash, return type : T.class) forall T #

[View source]
def write_query(cypher : String) #

Write data to this graph using the given Cypher query.

graph.write_query "MATCH (u:User{active: true}) SET u:ActiveUser, u.active = null"

[View source]
def write_query(cypher : String, **params) #

Write data to the graph using the given cypher query, passing in the given query parameters.


[View source]