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

Class Method Details

.avgObject

Cyrel DSL helper: Cypher avg() aggregation. Example: Cyrel.avg(:n)



225
# File 'lib/cyrel.rb', line 225

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

.coalesceObject

Cyrel DSL helper: Cypher coalesce() function. Example: Cyrel.coalesce(:a, :b)



197
# File 'lib/cyrel.rb', line 197

def coalesce(...) = Functions.coalesce(...)

.collectObject

Cyrel DSL helper: Cypher collect() aggregation. Example: Cyrel.collect(:n)



237
# File 'lib/cyrel.rb', line 237

def collect(...) = Functions.collect(...)

.countObject

Cyrel DSL helper: Cypher count() aggregation. Example: Cyrel.count(:n)



181
# File 'lib/cyrel.rb', line 181

def count(...) = Functions.count(...)

.create(pattern) ⇒ Object

Cyrel DSL helper: starts a CREATE query. Example: Cyrel.create(pattern)



152
153
154
# File 'lib/cyrel.rb', line 152

def create(pattern)
  Query.new.create(pattern)
end

.element_idObject

Cyrel DSL helper: returns the element id of a node/relationship (alias).



167
# File 'lib/cyrel.rb', line 167

def element_id(...) = Functions.element_id(...)

.exists(pattern) ⇒ Object

Cyrel DSL helper: creates an Exists expression. Example: Cyrel.exists(pattern)



251
252
253
# File 'lib/cyrel.rb', line 251

def exists(pattern)
  Expression.exists(pattern)
end

.exists_block(&block) ⇒ Object

Cyrel DSL helper: creates an EXISTS block with full subquery (Memgraph 3.5+). Example:

Cyrel.exists_block { match(Cyrel.node(:a) > Cyrel.rel(:r) > Cyrel.node(:b, :Admin)) }
# => EXISTS { MATCH (a)-[r]->(b:Admin) }


259
260
261
262
263
# File 'lib/cyrel.rb', line 259

def exists_block(&block)
  subquery = Query.new
  subquery.instance_eval(&block)
  Expression::ExistsBlock.new(subquery)
end

.function(name, *args) ⇒ Object

Cyrel DSL helper: creates a function call expression. Example: Cyrel.function(:count, :*)



175
176
177
# File 'lib/cyrel.rb', line 175

def function(name, *args)
  Expression::FunctionCall.new(name, args)
end

.idObject

Cyrel DSL helper: returns the element id of a node/relationship. Example: Cyrel.id(:n)



164
# File 'lib/cyrel.rb', line 164

def id(...) = Functions.id(...)

.labelsObject

Cyrel DSL helper: Cypher labels() function. Example: Cyrel.labels(:n)



185
# File 'lib/cyrel.rb', line 185

def labels(...) = Functions.labels(...)

.match(pattern, path_variable: nil) ⇒ Object

Cyrel DSL helper: starts a MATCH query. Example: Cyrel.match(pattern)



158
159
160
# File 'lib/cyrel.rb', line 158

def match(pattern, path_variable: nil)
  Query.new.match(pattern, path_variable: path_variable)
end

.maxObject

Cyrel DSL helper: Cypher max() aggregation. Example: Cyrel.max(:n)



233
# File 'lib/cyrel.rb', line 233

def max(...) = Functions.max(...)

.minObject

Cyrel DSL helper: Cypher min() aggregation. Example: Cyrel.min(:n)



229
# File 'lib/cyrel.rb', line 229

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_idObject

Cyrel DSL helper: adapter-aware node ID function Example: Cyrel.node_id(:n)



171
# File 'lib/cyrel.rb', line 171

def node_id(...) = Functions.node_id(...)

.not(expression) ⇒ Object

Cyrel DSL helper: creates a Logical NOT expression. Example: Cyrel.not(expression)



267
268
269
# File 'lib/cyrel.rb', line 267

def not(expression)
  Expression.not(expression)
end

.pathObject

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



274
275
276
# File 'lib/cyrel.rb', line 274

def plus(variable)
  Plus.new(variable)
end

.prop(variable, property_name) ⇒ Object

Cyrel DSL helper: creates a PropertyAccess expression. Example: Cyrel.prop(:n, :name)



245
246
247
# File 'lib/cyrel.rb', line 245

def prop(variable, property_name)
  Expression.prop(variable, property_name)
end

.propertiesObject

Cyrel DSL helper: Cypher properties() function. Example: Cyrel.properties(:n)



193
# File 'lib/cyrel.rb', line 193

def properties(...) = Functions.properties(...)

.queryObject

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

.sizeObject

Cyrel DSL helper: Cypher size() function. Example: Cyrel.size(:n)



241
# File 'lib/cyrel.rb', line 241

def size(...) = Functions.size(...)

.sumObject

Cyrel DSL helper: Cypher sum() aggregation. Example: Cyrel.sum(:n)



221
# File 'lib/cyrel.rb', line 221

def sum(...) = Functions.sum(...)

.timestampObject

Cyrel DSL helper: Cypher timestamp() function. Example: Cyrel.timestamp



201
# File 'lib/cyrel.rb', line 201

def timestamp(...) = Functions.timestamp(...)

.to_booleanObject

Cyrel DSL helper: Cypher toBoolean() function. Example: Cyrel.to_boolean(:n)



217
# File 'lib/cyrel.rb', line 217

def to_boolean(...) = Functions.to_boolean(...)

.to_floatObject

Cyrel DSL helper: Cypher toFloat() function. Example: Cyrel.to_float(:n)



213
# File 'lib/cyrel.rb', line 213

def to_float(...) = Functions.to_float(...)

.to_integerObject

Cyrel DSL helper: Cypher toInteger() function. Example: Cyrel.to_integer(:n)



209
# File 'lib/cyrel.rb', line 209

def to_integer(...) = Functions.to_integer(...)

.to_stringObject

Cyrel DSL helper: Cypher toString() function. Example: Cyrel.to_string(:n)



205
# File 'lib/cyrel.rb', line 205

def to_string(...) = Functions.to_string(...)

.typeObject

Cyrel DSL helper: Cypher type() function. Example: Cyrel.type(:r)



189
# File 'lib/cyrel.rb', line 189

def type(...) = Functions.type(...)