EctoNeo4j v0.6.3 Ecto.Adapters.Neo4j.Cql.Node View Source
Cypher query builder for Node
Link to this section Summary
Functions
Handle creation of unique constraints. Note that uniqueness on multiple properties is only available in Enterprise Edition
Builds a cypher for deleting a cosntraint or an index from the database.
Required a constraint cql similar to the one provided by CALL db.constraints()
Handle creation of non unique indexes.
Handle creation of non null constraints.
Returns cypher query to delete a node.
Returns cypher query to delete all database data.
Returns cypher query to delete all given nodes. This operation shoudl be performed as a btach for performance reason.
Handle deletion of unique constraints. Note that uniqueness on multiple properties is only available in Enterprise Edition
Builds a cypher for deleting a cosntraint or an index from the database.
Required a constraint cql similar to the one provided by CALL db.constraints()
Handle deletion of non unique indexes.
Handle deletion of non null constraints.
Returns cypher query and params to insert a new node.
Builds a cypher query for listing all the constraints for a specific node.
Builds a cypher query for listing all the indexes for a specific node.
Build a query to relabel a node.
Bulds a query to rename a property
Returns cypher query to update node data.
Link to this section Functions
create_constraint(node_label, columns) View Source
Handle creation of unique constraints. Note that uniqueness on multiple properties is only available in Enterprise Edition
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.create_constraint("Post", [:title])
"CREATE CONSTRAINT ON (n:Post) ASSERT n.title IS UNIQUE"
iex> Ecto.Adapters.Neo4j.Cql.Node.create_constraint("Post", [:title, :author])
"CREATE CONSTRAINT ON (n:Post) ASSERT (n.title, n.author) IS NODE KEY"
create_constraint_index_from_cql(cql) View Source
Builds a cypher for deleting a cosntraint or an index from the database.
Required a constraint cql similar to the one provided by CALL db.constraints()
Example
iex> constraint_cql = "CONSTRAINT ON ( posts:posts ) ASSERT posts.uuid IS UNIQUE"
iex> Ecto.Adapters.Neo4j.Cql.Node.create_constraint_index_from_cql(constraint_cql)
"CREATE CONSTRAINT ON ( posts:posts ) ASSERT posts.uuid IS UNIQUE"
iex> index_cql = "INDEX ON :posts(nodeId)"
iex> Ecto.Adapters.Neo4j.Cql.Node.create_constraint_index_from_cql(index_cql)
"CREATE INDEX ON :posts(nodeId)"
create_index(node_label, columns) View Source
Handle creation of non unique indexes.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.create_index("Post", [:title])
"CREATE INDEX ON :Post(title)"
iex> Ecto.Adapters.Neo4j.Cql.Node.create_index("Post", [:title, :author])
"CREATE INDEX ON :Post(title, author)"
create_non_null_constraint(node_label, column) View Source
Handle creation of non null constraints.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.create_non_null_constraint("Post", :title)
"CREATE CONSTRAINT ON (n:Post) ASSERT exists(n.title)"
delete(node_label, filters) View Source
Returns cypher query to delete a node.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.delete("Post", %{uuid: "a-valid-uuid"})
{"MATCH
(n:Post)
WHERE
n.uuid = {uuid}
DETACH DELETE
n
RETURN
n
", %{uuid: "a-valid-uuid"}}
delete_all()
View Source
delete_all() :: String.t()
delete_all() :: String.t()
Returns cypher query to delete all database data.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.delete_all()
"MATCH
(n)
DETACH DELETE
n
"
delete_nodes(node_label) View Source
Returns cypher query to delete all given nodes. This operation shoudl be performed as a btach for performance reason.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.delete_nodes("Post")
"MATCH
(n:Post)
WITH
n AS n
LIMIT
{limit}
DETACH DELETE
n
RETURN
COUNT(n) AS nb_touched_nodes
"
drop_constraint(node_label, columns) View Source
Handle deletion of unique constraints. Note that uniqueness on multiple properties is only available in Enterprise Edition
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.drop_constraint("Post", [:title])
"DROP CONSTRAINT ON (n:Post) ASSERT n.title IS UNIQUE"
iex> Ecto.Adapters.Neo4j.Cql.Node.drop_constraint("Post", [:title, :author])
"DROP CONSTRAINT ON (n:Post) ASSERT (n.title, n.author) IS NODE KEY"
drop_constraint_index_from_cql(cql) View Source
Builds a cypher for deleting a cosntraint or an index from the database.
Required a constraint cql similar to the one provided by CALL db.constraints()
Example
iex> constraint_cql = "CONSTRAINT ON ( posts:posts ) ASSERT posts.uuid IS UNIQUE"
iex> Ecto.Adapters.Neo4j.Cql.Node.drop_constraint_index_from_cql(constraint_cql)
"DROP CONSTRAINT ON ( posts:posts ) ASSERT posts.uuid IS UNIQUE"
iex> index_cql = "INDEX ON :posts(nodeId)"
iex> Ecto.Adapters.Neo4j.Cql.Node.drop_constraint_index_from_cql(index_cql)
"DROP INDEX ON :posts(nodeId)"
drop_index(node_label, columns) View Source
Handle deletion of non unique indexes.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.drop_index("Post", [:title])
"DROP INDEX ON :Post(title)"
iex> Ecto.Adapters.Neo4j.Cql.Node.drop_index("Post", [:title, :author])
"DROP INDEX ON :Post(title, author)"
drop_non_null_constraint(node_label, column) View Source
Handle deletion of non null constraints.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.drop_non_null_constraint("Post", :title)
"DROP CONSTRAINT ON (n:Post) ASSERT exists(n.title)"
insert(node_label, data, primary_keys, return \\ []) View Source
Returns cypher query and params to insert a new node.
Example
iex> data = %{title: "New title", uuid: "a-valid-uuid"}
iex> Ecto.Adapters.Neo4j.Cql.Node.insert("Post", data, [:uuid])
{"MERGE
(n:Post {uuid: {uuid}})
ON CREATE SET
n.title = {title}, \nn.uuid = {uuid}\n
RETURN
n
", %{title: "New title", uuid: "a-valid-uuid"}}
# With returning fields specified
iex> data = %{title: "New title", uuid: "a-valid-uuid"}
iex> Ecto.Adapters.Neo4j.Cql.Node.insert("Post", data, [:uuid], [:uuid])
{"MERGE
(n:Post {uuid: {uuid}})
ON CREATE SET
n.title = {title}, \nn.uuid = {uuid}\n
RETURN
n.uuid AS uuid
", %{title: "New title", uuid: "a-valid-uuid"}}
list_all_constraints(node_label, property \\ nil) View Source
Builds a cypher query for listing all the constraints for a specific node.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.list_all_constraints("Post")
"CALL db.constraints()
YIELD description
WHERE description CONTAINS \":Post\" \nRETURN description
"
iex> Ecto.Adapters.Neo4j.Cql.Node.list_all_constraints("Post", :title)
"CALL db.constraints()
YIELD description
WHERE description CONTAINS \":Post\" AND description CONTAINS '.title'
RETURN description
"
list_all_indexes(node_label, property \\ nil) View Source
Builds a cypher query for listing all the indexes for a specific node.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.list_all_indexes("Post")
"CALL db.indexes()
YIELD description
WHERE description CONTAINS \":Post\" \nRETURN description
"
iex> Ecto.Adapters.Neo4j.Cql.Node.list_all_indexes("Post", :title)
"CALL db.indexes()
YIELD description
WHERE description CONTAINS \":Post\" AND description CONTAINS 'title'
RETURN description
"
relabel(old_label, new_label) View Source
Build a query to relabel a node.
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.relabel("Post", "NewPost")
"MATCH
(n:Post)
WITH
n AS n
LIMIT
{limit}
SET
n:NewPost
REMOVE
n:Post
RETURN
COUNT(n) AS nb_touched_nodes
"
rename_property(node_label, old_name, new_name) View Source
Bulds a query to rename a property
Example
iex> Ecto.Adapters.Neo4j.Cql.Node.rename_property("Post", "titttle", "title")
"MATCH
(n:Post)
WITH
n AS n
SKIP
{skip}
LIMIT
{limit}
SET
n.title = n.titttle
REMOVE
n.titttle
RETURN
COUNT(n) AS nb_touched_nodes
"
update(node_label, data, filters \\ %{}) View Source
Returns cypher query to update node data.
Example
iex> data = %{title: "New title"}
iex> filters = %{id: 5}
iex> Ecto.Adapters.Neo4j.Cql.Node.update("Post", data, filters)
{"MATCH
(n:Post)
WHERE
n.id = {f_id}
SET
n.title = {title}
RETURN
n
", %{f_id: 5, title: "New title"}}