AshNeo4j.Cypher (AshNeo4j v0.2.6)

View Source

AshNeo4j Cypher

Summary

Functions

Converts a node variable, label and optional properties to cypher expression

Converts a node variable, label and optional properties to cypher node.

Converts a map to a cypher properties string. The map is converted to a string in the format {key1: value1, key2: value2}.

Converts a node_relationship tuple to cypher clause, ignoring the label

Converts a relationship variable, label and optional direction to cypher relationship.

Converts a list into a remove properties string. The list is converted to a string in the format n.key1, n.key2.

Runs some cypher

Functions

expression(variable, left, operator, right)

Converts a node variable, label and optional properties to cypher expression

Examples

iex> AshNeo4j.Cypher.expression(:s, "name", "in", "[Bill Nighy]")
"s.name in [Bill Nighy]"
iex> AshNeo4j.Cypher.expression(:s, "name", "in", "[]")
"s.name IS NULL"
iex> AshNeo4j.Cypher.expression(:s, "name", "is_nil", true)
"s.name IS NULL"
iex> AshNeo4j.Cypher.expression(:s, "name", "is_nil", false)
"s.name IS NOT NULL"
iex> AshNeo4j.Cypher.expression(:s, "name", "contains", "access")
"s.name CONTAINS 'access'"

node(variable, label, properties \\ %{})

Converts a node variable, label and optional properties to cypher node.

Examples

iex> AshNeo4j.Cypher.node(:s, :Actor)
"(s:Actor)"
iex> AshNeo4j.Cypher.node(:s, :Actor, %{name: "Bill Nighy"})
"(s:Actor {name: 'Bill Nighy'})"

properties(map)

Converts a map to a cypher properties string. The map is converted to a string in the format {key1: value1, key2: value2}.

Examples

iex> AshNeo4j.Cypher.properties(%{name: "Bill Nighy", born: 1949, bafta_winner: true})
"{name: 'Bill Nighy', born: 1949, bafta_winner: true}"

relationship(node_relationship)

Converts a node_relationship tuple to cypher clause, ignoring the label

Examples

iex> AshNeo4j.Cypher.relationship({:movies, :ACTED_IN, :outgoing})
"-[r:ACTED_IN]->"
iex> AshNeo4j.Cypher.relationship(nil)
"-[r]-"

relationship(variable, label, direction \\ nil)

Converts a relationship variable, label and optional direction to cypher relationship.

Examples

iex> AshNeo4j.Cypher.relationship(:r, :ACTED_IN, :outgoing)
"-[r:ACTED_IN]->"
iex> AshNeo4j.Cypher.relationship(:r, :ACTED_IN, :incoming)
"<-[r:ACTED_IN]-"
iex> AshNeo4j.Cypher.relationship(:r, :KNOWS)
"-[r:KNOWS]-"

remove_properties(label, list)

Converts a list into a remove properties string. The list is converted to a string in the format n.key1, n.key2.

Examples

iex> AshNeo4j.Cypher.remove_properties(:n, [:born, :bafta_winner])
"n.born, n.bafta_winner"

run(cypher)

Runs some cypher

Examples

iex> cypher = "CREATE (n:Actor {name: 'Bill Nighy', born: 1949, bafta_winner: true}) RETURN n"
iex> {result, _} = AshNeo4j.Cypher.run(cypher)
iex> result
:ok

run_expecting_deletions(cypher)