Module: Cyrel
- Defined in:
- lib/cyrel.rb,
lib/cyrel/node.rb,
lib/cyrel/plus.rb,
lib/cyrel/query.rb,
lib/cyrel/clause.rb,
lib/cyrel/logging.rb,
lib/cyrel/pattern.rb,
lib/cyrel/ast/node.rb,
lib/cyrel/direction.rb,
lib/cyrel/functions.rb,
lib/cyrel/clause/set.rb,
lib/cyrel/expression.rb,
lib/cyrel/clause/call.rb,
lib/cyrel/clause/skip.rb,
lib/cyrel/clause/with.rb,
lib/cyrel/return_only.rb,
lib/cyrel/ast/compiler.rb,
lib/cyrel/ast/set_node.rb,
lib/cyrel/clause/limit.rb,
lib/cyrel/clause/match.rb,
lib/cyrel/clause/merge.rb,
lib/cyrel/clause/where.rb,
lib/cyrel/pattern/node.rb,
lib/cyrel/pattern/path.rb,
lib/cyrel/ast/call_node.rb,
lib/cyrel/ast/skip_node.rb,
lib/cyrel/ast/with_node.rb,
lib/cyrel/clause/create.rb,
lib/cyrel/clause/delete.rb,
lib/cyrel/clause/remove.rb,
lib/cyrel/clause/return.rb,
lib/cyrel/clause/unwind.rb,
lib/cyrel/ast/limit_node.rb,
lib/cyrel/ast/match_node.rb,
lib/cyrel/ast/merge_node.rb,
lib/cyrel/ast/union_node.rb,
lib/cyrel/ast/where_node.rb,
lib/cyrel/call_procedure.rb,
lib/cyrel/ast/clause_node.rb,
lib/cyrel/ast/create_node.rb,
lib/cyrel/ast/delete_node.rb,
lib/cyrel/ast/remove_node.rb,
lib/cyrel/ast/return_node.rb,
lib/cyrel/ast/unwind_node.rb,
lib/cyrel/clause/order_by.rb,
lib/cyrel/expression/base.rb,
lib/cyrel/expression/case.rb,
lib/cyrel/parameterizable.rb,
lib/cyrel/types/hash_type.rb,
lib/cyrel/ast/foreach_node.rb,
lib/cyrel/ast/literal_node.rb,
lib/cyrel/ast/pattern_node.rb,
lib/cyrel/expression/alias.rb,
lib/cyrel/ast/load_csv_node.rb,
lib/cyrel/ast/order_by_node.rb,
lib/cyrel/expression/exists.rb,
lib/cyrel/types/symbol_type.rb,
lib/cyrel/ast/clause_adapter.rb,
lib/cyrel/expression/literal.rb,
lib/cyrel/expression/logical.rb,
lib/cyrel/ast/expression_node.rb,
lib/cyrel/ast/optimized_nodes.rb,
lib/cyrel/expression/operator.rb,
lib/cyrel/clause/call_subquery.rb,
lib/cyrel/pattern/relationship.rb,
lib/cyrel/expression/comparison.rb,
lib/cyrel/expression/function_call.rb,
lib/cyrel/expression/property_access.rb,
lib/cyrel/ast/query_integrated_compiler.rb,
lib/cyrel/expression/pattern_comprehension.rb
Defined Under Namespace
Modules: AST, Clause, Direction, Expression, Functions, Logging, Parameterizable, Pattern, Types Classes: AliasConflictError, CallProcedure, Node, PathBuilder, Plus, Query, ReturnOnly
Class Method Summary collapse
-
.avg ⇒ Object
Cyrel DSL helper: Cypher avg() aggregation.
-
.call(procedure) ⇒ Object
Cyrel DSL helper: creates a CALL clause for a procedure.
-
.coalesce ⇒ Object
Cyrel DSL helper: Cypher coalesce() function.
-
.collect ⇒ Object
Cyrel DSL helper: Cypher collect() aggregation.
-
.count ⇒ Object
Cyrel DSL helper: Cypher count() aggregation.
-
.create(pattern) ⇒ Object
Cyrel DSL helper: starts a CREATE query.
-
.element_id ⇒ Object
Cyrel DSL helper: returns the element id of a node/relationship (alias).
-
.exists(pattern) ⇒ Object
Cyrel DSL helper: creates an Exists expression.
-
.exists_block ⇒ Object
Cyrel DSL helper: creates an EXISTS block with full subquery (Memgraph 3.5+).
-
.function(name, *args) ⇒ Object
Cyrel DSL helper: creates a function call expression.
-
.id ⇒ Object
Cyrel DSL helper: returns the element id of a node/relationship.
-
.labels ⇒ Object
Cyrel DSL helper: Cypher labels() function.
-
.match(pattern, path_variable: nil) ⇒ Object
Cyrel DSL helper: starts a MATCH query.
-
.max ⇒ Object
Cyrel DSL helper: Cypher max() aggregation.
-
.min ⇒ Object
Cyrel DSL helper: Cypher min() aggregation.
-
.n(alias_name = nil, *labels, or_labels: nil, **properties) ⇒ Object
Cyrel DSL helper: alias for node creation.
-
.node(alias_name = nil, *labels, or_labels: nil, **properties) ⇒ Object
Cyrel DSL helper: creates a node pattern.
-
.node_id ⇒ Object
Cyrel DSL helper: adapter-aware node ID function Example: Cyrel.node_id(:n).
-
.not(expression) ⇒ Object
Cyrel DSL helper: creates a Logical NOT expression.
-
.path ⇒ Object
Cyrel DSL helper: creates a path pattern with a DSL block.
-
.plus(variable) ⇒ Object
Cyrel DSL helper: property merging (SET n += props).
-
.prop(variable, property_name) ⇒ Object
Cyrel DSL helper: creates a PropertyAccess expression.
-
.properties ⇒ Object
Cyrel DSL helper: Cypher properties() function.
-
.query ⇒ Object
Cyrel DSL helper: creates a new query.
-
.rel(alias_name = nil, *types, **properties) ⇒ Object
Cyrel DSL helper: creates a relationship pattern.
-
.return(**return_values) ⇒ Object
Cyrel DSL helper: creates a RETURN clause.
-
.size ⇒ Object
Cyrel DSL helper: Cypher size() function.
-
.sum ⇒ Object
Cyrel DSL helper: Cypher sum() aggregation.
-
.timestamp ⇒ Object
Cyrel DSL helper: Cypher timestamp() function.
-
.to_boolean ⇒ Object
Cyrel DSL helper: Cypher toBoolean() function.
-
.to_float ⇒ Object
Cyrel DSL helper: Cypher toFloat() function.
-
.to_integer ⇒ Object
Cyrel DSL helper: Cypher toInteger() function.
-
.to_string ⇒ Object
Cyrel DSL helper: Cypher toString() function.
-
.type ⇒ Object
Cyrel DSL helper: Cypher type() function.
Class Method Details
.avg ⇒ Object
Cyrel DSL helper: Cypher avg() aggregation. Example: Cyrel.avg(:n)
204 |
# File 'lib/cyrel.rb', line 204 def avg(...) = Functions.avg(...) |
.call(procedure) ⇒ Object
Cyrel DSL helper: creates a CALL clause for a procedure. Example: Cyrel.call(‘db.labels’)
21 22 23 |
# File 'lib/cyrel.rb', line 21 def call(procedure) CallProcedure.new(procedure) end |
.coalesce ⇒ Object
Cyrel DSL helper: Cypher coalesce() function. Example: Cyrel.coalesce(:a, :b)
176 |
# File 'lib/cyrel.rb', line 176 def coalesce(...) = Functions.coalesce(...) |
.collect ⇒ Object
Cyrel DSL helper: Cypher collect() aggregation. Example: Cyrel.collect(:n)
216 |
# File 'lib/cyrel.rb', line 216 def collect(...) = Functions.collect(...) |
.count ⇒ Object
Cyrel DSL helper: Cypher count() aggregation. Example: Cyrel.count(:n)
160 |
# File 'lib/cyrel.rb', line 160 def count(...) = Functions.count(...) |
.create(pattern) ⇒ Object
Cyrel DSL helper: starts a CREATE query. Example: Cyrel.create(pattern)
131 132 133 |
# File 'lib/cyrel.rb', line 131 def create(pattern) Query.new.create(pattern) end |
.element_id ⇒ Object
Cyrel DSL helper: returns the element id of a node/relationship (alias).
146 |
# File 'lib/cyrel.rb', line 146 def element_id(...) = Functions.element_id(...) |
.exists(pattern) ⇒ Object
Cyrel DSL helper: creates an Exists expression. Example: Cyrel.exists(pattern)
230 231 232 |
# File 'lib/cyrel.rb', line 230 def exists(pattern) Expression.exists(pattern) end |
.exists_block ⇒ Object
238 239 240 241 242 |
# File 'lib/cyrel.rb', line 238 def exists_block(&) subquery = Query.new subquery.instance_eval(&) Expression::ExistsBlock.new(subquery) end |
.function(name, *args) ⇒ Object
Cyrel DSL helper: creates a function call expression. Example: Cyrel.function(:count, :*)
154 155 156 |
# File 'lib/cyrel.rb', line 154 def function(name, *args) Expression::FunctionCall.new(name, args) end |
.id ⇒ Object
Cyrel DSL helper: returns the element id of a node/relationship. Example: Cyrel.id(:n)
143 |
# File 'lib/cyrel.rb', line 143 def id(...) = Functions.id(...) |
.labels ⇒ Object
Cyrel DSL helper: Cypher labels() function. Example: Cyrel.labels(:n)
164 |
# File 'lib/cyrel.rb', line 164 def labels(...) = Functions.labels(...) |
.match(pattern, path_variable: nil) ⇒ Object
Cyrel DSL helper: starts a MATCH query. Example: Cyrel.match(pattern)
137 138 139 |
# File 'lib/cyrel.rb', line 137 def match(pattern, path_variable: nil) Query.new.match(pattern, path_variable: path_variable) end |
.max ⇒ Object
Cyrel DSL helper: Cypher max() aggregation. Example: Cyrel.max(:n)
212 |
# File 'lib/cyrel.rb', line 212 def max(...) = Functions.max(...) |
.min ⇒ Object
Cyrel DSL helper: Cypher min() aggregation. Example: Cyrel.min(:n)
208 |
# File 'lib/cyrel.rb', line 208 def min(...) = Functions.min(...) |
.n(alias_name = nil, *labels, or_labels: nil, **properties) ⇒ Object
Cyrel DSL helper: alias for node creation. Example: Cyrel.n(:person, :Person, name: ‘Alice’) Example: Cyrel.n(:n, or_labels: [:Person, :Organization]) # Memgraph 3.2+
15 16 17 |
# File 'lib/cyrel.rb', line 15 def n(alias_name = nil, *labels, or_labels: nil, **properties) Pattern::Node.new(alias_name, labels: labels, or_labels: or_labels, properties: properties) end |
.node(alias_name = nil, *labels, or_labels: nil, **properties) ⇒ Object
Cyrel DSL helper: creates a node pattern. Example: Cyrel.node(:n, :Person, name: ‘Alice’) Example: Cyrel.node(:n, or_labels: [:Person, :Organization]) # Memgraph 3.2+
34 35 36 |
# File 'lib/cyrel.rb', line 34 def node(alias_name = nil, *labels, or_labels: nil, **properties) Pattern::Node.new(alias_name, labels: labels, or_labels: or_labels, properties: properties) end |
.node_id ⇒ Object
Cyrel DSL helper: adapter-aware node ID function Example: Cyrel.node_id(:n)
150 |
# File 'lib/cyrel.rb', line 150 def node_id(...) = Functions.node_id(...) |
.not(expression) ⇒ Object
Cyrel DSL helper: creates a Logical NOT expression. Example: Cyrel.not(expression)
246 247 248 |
# File 'lib/cyrel.rb', line 246 def not(expression) Expression.not(expression) end |
.path ⇒ Object
Cyrel DSL helper: creates a path pattern with a DSL block. Example: Cyrel.path { node(:a) > rel(:r) > node(:b) }
47 48 49 50 51 |
# File 'lib/cyrel.rb', line 47 def path(&) builder = PathBuilder.new builder.instance_eval(&) Pattern::Path.new(builder.elements) end |
.plus(variable) ⇒ Object
Cyrel DSL helper: property merging (SET n = {props}). Use for updating only specified properties on a node or relationship. Example: Cyrel.plus(:n) => { name: “Alice” } generates SET n = $p1
253 254 255 |
# File 'lib/cyrel.rb', line 253 def plus(variable) Plus.new(variable) end |
.prop(variable, property_name) ⇒ Object
Cyrel DSL helper: creates a PropertyAccess expression. Example: Cyrel.prop(:n, :name)
224 225 226 |
# File 'lib/cyrel.rb', line 224 def prop(variable, property_name) Expression.prop(variable, property_name) end |
.properties ⇒ Object
Cyrel DSL helper: Cypher properties() function. Example: Cyrel.properties(:n)
172 |
# File 'lib/cyrel.rb', line 172 def properties(...) = Functions.properties(...) |
.query ⇒ Object
Cyrel DSL helper: creates a new query. Example: Cyrel.query.match(pattern)
8 9 10 |
# File 'lib/cyrel.rb', line 8 def query Query.new end |
.rel(alias_name = nil, *types, **properties) ⇒ Object
Cyrel DSL helper: creates a relationship pattern. Example: Cyrel.rel(:r, :KNOWS, since: 2020)
40 41 42 43 |
# File 'lib/cyrel.rb', line 40 def rel(alias_name = nil, *types, **properties) length = properties.delete(:length) Pattern::Relationship.new(alias_name: alias_name, types: types, properties: properties, length: length) end |
.return(**return_values) ⇒ Object
Cyrel DSL helper: creates a RETURN clause. Example: Cyrel.return(name: :n)
27 28 29 |
# File 'lib/cyrel.rb', line 27 def return(**return_values) ReturnOnly.new(return_values) end |
.size ⇒ Object
Cyrel DSL helper: Cypher size() function. Example: Cyrel.size(:n)
220 |
# File 'lib/cyrel.rb', line 220 def size(...) = Functions.size(...) |
.sum ⇒ Object
Cyrel DSL helper: Cypher sum() aggregation. Example: Cyrel.sum(:n)
200 |
# File 'lib/cyrel.rb', line 200 def sum(...) = Functions.sum(...) |
.timestamp ⇒ Object
Cyrel DSL helper: Cypher timestamp() function. Example: Cyrel.timestamp
180 |
# File 'lib/cyrel.rb', line 180 def (...) = Functions.(...) |
.to_boolean ⇒ Object
Cyrel DSL helper: Cypher toBoolean() function. Example: Cyrel.to_boolean(:n)
196 |
# File 'lib/cyrel.rb', line 196 def to_boolean(...) = Functions.to_boolean(...) |
.to_float ⇒ Object
Cyrel DSL helper: Cypher toFloat() function. Example: Cyrel.to_float(:n)
192 |
# File 'lib/cyrel.rb', line 192 def to_float(...) = Functions.to_float(...) |
.to_integer ⇒ Object
Cyrel DSL helper: Cypher toInteger() function. Example: Cyrel.to_integer(:n)
188 |
# File 'lib/cyrel.rb', line 188 def to_integer(...) = Functions.to_integer(...) |