Module: Fauna::Query
Overview
Helpers modeling the FaunaDB Query language.
Helpers are usually used via a concise DSL notation. A DSL block may be used directly with Fauna::Client
client.query { create(class_('spells'), { data: { name: 'Magic Missile' } }) }
To build and return an query expression to execute later, use Fauna::Query.expr
Fauna::Query.expr { create(class_('spells'), { data: { name: 'Magic Missile' } }) }
Or, you may directly use the helper methods:
Fauna::Query.create(Fauna::Query.class_('spells'), { data: { name: 'Magic Missile' } })
Defined Under Namespace
Classes: Expr, QueryDSLContext
Class Method Summary collapse
-
.expr(&block) ⇒ Object
Build a query expression.
Instance Method Summary collapse
-
#abort(msg) ⇒ Object
An abort expression.
-
#add(*numbers) ⇒ Object
An add function.
-
#and_(*booleans) ⇒ Object
An and function.
-
#append(collection, elements) ⇒ Object
An append expression.
-
#at(timestamp, expr) ⇒ Object
An at expression.
-
#call(name, *args) ⇒ Object
A call expression.
-
#casefold(string, normalizer = nil) ⇒ Object
A casefold function.
-
#class_(name, scope = nil) ⇒ Object
A class function.
-
#classes(scope = nil) ⇒ Object
A classes function.
-
#concat(strings, separator = nil) ⇒ Object
A concat function.
-
#contains(path, in_) ⇒ Object
A contains function.
-
#create(class_ref, params) ⇒ Object
A create expression.
-
#create_class(params) ⇒ Object
A create class expression.
-
#create_database(params) ⇒ Object
A create database expression.
-
#create_function(params) ⇒ Object
A create function expression.
-
#create_index(params) ⇒ Object
A create index expression.
-
#create_key(params) ⇒ Object
A create key expression.
-
#credentials(scope = nil) ⇒ Object
A credentials function.
-
#database(name, scope = nil) ⇒ Object
A database function.
-
#databases(scope = nil) ⇒ Object
A databases function.
-
#date(string) ⇒ Object
A date expression.
-
#delete(ref) ⇒ Object
A delete expression.
-
#difference(*sets) ⇒ Object
A difference expression.
-
#distinct(set) ⇒ Object
A distinct expression.
-
#divide(*numbers) ⇒ Object
A divide function.
-
#do_(*expressions) ⇒ Object
A do expression.
-
#drop(number, collection) ⇒ Object
A drop expression.
-
#epoch(number, unit) ⇒ Object
An epoch expression.
-
#equals(*values) ⇒ Object
An equals function.
-
#events(ref_set) ⇒ Object
An events expression.
-
#exists(ref, params = {}) ⇒ Object
An exists expression.
-
#filter(collection, lambda_expr = nil, &lambda_block) ⇒ Object
A filter expression.
-
#foreach(collection, lambda_expr = nil, &lambda_block) ⇒ Object
A foreach expression.
-
#function(name, scope = nil) ⇒ Object
A function function.
-
#functions(scope = nil) ⇒ Object
A functions function.
-
#get(ref, params = {}) ⇒ Object
A get expression.
-
#gt(*values) ⇒ Object
A greater than function.
-
#gte(*values) ⇒ Object
A greater than or equal function.
-
#has_identity ⇒ Object
A has_identity function.
-
#identify(ref, password) ⇒ Object
An identify function.
-
#identity ⇒ Object
An identity function.
-
#if_(condition, then_, else_) ⇒ Object
An if expression.
-
#index(name, scope = nil) ⇒ Object
An index function.
-
#indexes(scope = nil) ⇒ Object
An indexes function.
-
#insert(ref, ts, action, params) ⇒ Object
An insert expression.
-
#intersection(*sets) ⇒ Object
An intersection expression.
-
#join(source, target_expr = nil, &target_block) ⇒ Object
A join expression.
-
#key_from_secret(secret) ⇒ Object
A key_from_secret expression.
-
#keys(scope = nil) ⇒ Object
A keys function.
-
#lambda(&block) ⇒ Object
A lambda expression.
-
#lambda_expr(var, expr) ⇒ Object
A raw lambda expression.
-
#let(vars, expr = nil, &block) ⇒ Object
A let expression.
-
#login(ref, params) ⇒ Object
A login function.
-
#logout(all_tokens) ⇒ Object
A logout function.
-
#lt(*values) ⇒ Object
A less than function.
-
#lte(*values) ⇒ Object
A less than or equal function.
-
#map(collection, lambda_expr = nil, &lambda_block) ⇒ Object
A map expression.
-
#match(index, *terms) ⇒ Object
A match expression.
-
#modulo(*numbers) ⇒ Object
A modulo function.
-
#multiply(*numbers) ⇒ Object
A multiply function.
-
#new_id ⇒ Object
A new_id function.
-
#next_id ⇒ Object
A next_id function.
-
#not_(boolean) ⇒ Object
A not function.
-
#object(fields) ⇒ Object
An object expression.
-
#or_(*booleans) ⇒ Object
An or function.
-
#paginate(set, params = {}) ⇒ Object
A paginate expression.
-
#prepend(collection, elements) ⇒ Object
A prepend expression.
-
#query(expr) ⇒ Object
A query expression.
-
#ref(str, id = nil) ⇒ Object
Construct a ref value.
-
#remove(ref, ts, action) ⇒ Object
A remove expression.
-
#replace(ref, params) ⇒ Object
A replace expression.
-
#select(path, from, params = {}) ⇒ Object
A select function.
-
#select_all(path, from) ⇒ Object
A select_all function.
-
#singleton(ref) ⇒ Object
A singleton expression.
-
#subtract(*numbers) ⇒ Object
A subtract function.
-
#take(number, collection) ⇒ Object
A take expression.
-
#time(string) ⇒ Object
A time expression.
-
#tokens(scope = nil) ⇒ Object
A tokens function.
-
#union(*sets) ⇒ Object
A union expression.
-
#update(ref, params) ⇒ Object
An update expression.
-
#var(name) ⇒ Object
A var expression.
Methods included from Deprecate
Class Method Details
.expr(&block) ⇒ Object
Build a query expression.
Allows for unscoped calls to Fauna::Query methods within the provided block. The block should return the constructed query expression.
Example: Fauna::Query.expr { add(1, 2, subtract(3, 2)) }
32 33 34 35 36 37 38 |
# File 'lib/fauna/query.rb', line 32 def self.expr(&block) return nil if block.nil? dsl = QueryDSLContext.new Expr.wrap DSLContext.eval_dsl(dsl, &block) end |
Instance Method Details
#abort(msg) ⇒ Object
An abort expression
Reference: FaunaDB Basic Forms
58 59 60 |
# File 'lib/fauna/query.rb', line 58 def abort(msg) Expr.new abort: Expr.wrap(msg) end |
#add(*numbers) ⇒ Object
An add function
Reference: FaunaDB Miscellaneous Functions
707 708 709 |
# File 'lib/fauna/query.rb', line 707 def add(*numbers) Expr.new add: Expr.wrap_varargs(numbers) end |
#and_(*booleans) ⇒ Object
An and function
Reference: FaunaDB Miscellaneous Functions
779 780 781 |
# File 'lib/fauna/query.rb', line 779 def and_(*booleans) Expr.new and: Expr.wrap_varargs(booleans) end |
#append(collection, elements) ⇒ Object
An append expression
Reference: FaunaDB Collections
264 265 266 |
# File 'lib/fauna/query.rb', line 264 def append(collection, elements) Expr.new append: Expr.wrap(elements), collection: Expr.wrap(collection) end |
#at(timestamp, expr) ⇒ Object
An at expression
Reference: FaunaDB Basic Forms
89 90 91 |
# File 'lib/fauna/query.rb', line 89 def at(, expr) Expr.new at: Expr.wrap(), expr: Expr.wrap(expr) end |
#call(name, *args) ⇒ Object
A call expression
Reference: FaunaDB Basic Forms
197 198 199 |
# File 'lib/fauna/query.rb', line 197 def call(name, *args) Expr.new call: Expr.wrap(name), arguments: Expr.wrap_varargs(args) end |
#casefold(string, normalizer = nil) ⇒ Object
A casefold function
Reference: FaunaDB String Functions
521 522 523 524 525 526 527 |
# File 'lib/fauna/query.rb', line 521 def casefold(string, normalizer = nil) if normalizer.nil? Expr.new casefold: Expr.wrap(string) else Expr.new casefold: Expr.wrap(string), normalizer: Expr.wrap(normalizer) end end |
#class_(name, scope = nil) ⇒ Object
A class function
Reference: FaunaDB Miscellaneous Functions
589 590 591 592 593 |
# File 'lib/fauna/query.rb', line 589 def class_(name, scope = nil) return Expr.new class: Expr.wrap(name) if scope.nil? Expr.new class: Expr.wrap(name), scope: Expr.wrap(scope) end |
#classes(scope = nil) ⇒ Object
A classes function
Reference: FaunaDB Miscellaneous Functions
627 628 629 |
# File 'lib/fauna/query.rb', line 627 def classes(scope = nil) Expr.new classes: Expr.wrap(scope) end |
#concat(strings, separator = nil) ⇒ Object
A concat function
Reference: FaunaDB String Functions
509 510 511 512 513 514 515 |
# File 'lib/fauna/query.rb', line 509 def concat(strings, separator = nil) if separator.nil? Expr.new concat: Expr.wrap(strings) else Expr.new concat: Expr.wrap(strings), separator: Expr.wrap(separator) end end |
#contains(path, in_) ⇒ Object
A contains function
Reference: FaunaDB Miscellaneous Functions
683 684 685 |
# File 'lib/fauna/query.rb', line 683 def contains(path, in_) Expr.new contains: Expr.wrap(path), in: Expr.wrap(in_) end |
#create(class_ref, params) ⇒ Object
A create expression
Reference: FaunaDB Write functions
308 309 310 |
# File 'lib/fauna/query.rb', line 308 def create(class_ref, params) Expr.new create: Expr.wrap(class_ref), params: Expr.wrap(params) end |
#create_class(params) ⇒ Object
A create class expression
Reference: FaunaDB Write functions
356 357 358 |
# File 'lib/fauna/query.rb', line 356 def create_class(params) Expr.new create_class: Expr.wrap(params) end |
#create_database(params) ⇒ Object
A create database expression
Reference: FaunaDB Write functions
372 373 374 |
# File 'lib/fauna/query.rb', line 372 def create_database(params) Expr.new create_database: Expr.wrap(params) end |
#create_function(params) ⇒ Object
A create function expression
Reference: FaunaDB Write functions
388 389 390 |
# File 'lib/fauna/query.rb', line 388 def create_function(params) Expr.new create_function: Expr.wrap(params) end |
#create_index(params) ⇒ Object
A create index expression
Reference: FaunaDB Write functions
364 365 366 |
# File 'lib/fauna/query.rb', line 364 def create_index(params) Expr.new create_index: Expr.wrap(params) end |
#create_key(params) ⇒ Object
A create key expression
Reference: FaunaDB Write functions
380 381 382 |
# File 'lib/fauna/query.rb', line 380 def create_key(params) Expr.new create_key: Expr.wrap(params) end |
#credentials(scope = nil) ⇒ Object
A credentials function
Reference: FaunaDB Miscellaneous Functions
667 668 669 |
# File 'lib/fauna/query.rb', line 667 def credentials(scope = nil) Expr.new credentials: Expr.wrap(scope) end |
#database(name, scope = nil) ⇒ Object
A database function
Reference: FaunaDB Miscellaneous Functions
579 580 581 582 583 |
# File 'lib/fauna/query.rb', line 579 def database(name, scope = nil) return Expr.new database: Expr.wrap(name) if scope.nil? Expr.new database: Expr.wrap(name), scope: Expr.wrap(scope) end |
#databases(scope = nil) ⇒ Object
A databases function
Reference: FaunaDB Miscellaneous Functions
619 620 621 |
# File 'lib/fauna/query.rb', line 619 def databases(scope = nil) Expr.new databases: Expr.wrap(scope) end |
#date(string) ⇒ Object
A date expression
Reference: FaunaDB Time Functions
551 552 553 |
# File 'lib/fauna/query.rb', line 551 def date(string) Expr.new date: Expr.wrap(string) end |
#delete(ref) ⇒ Object
A delete expression
Reference: FaunaDB Write functions
332 333 334 |
# File 'lib/fauna/query.rb', line 332 def delete(ref) Expr.new delete: Expr.wrap(ref) end |
#difference(*sets) ⇒ Object
A difference expression
Reference: FaunaDB Sets
438 439 440 |
# File 'lib/fauna/query.rb', line 438 def difference(*sets) Expr.new difference: Expr.wrap_varargs(sets) end |
#distinct(set) ⇒ Object
A distinct expression
Reference: FaunaDB Sets
446 447 448 |
# File 'lib/fauna/query.rb', line 446 def distinct(set) Expr.new distinct: Expr.wrap(set) end |
#divide(*numbers) ⇒ Object
A divide function
Reference: FaunaDB Miscellaneous Functions
731 732 733 |
# File 'lib/fauna/query.rb', line 731 def divide(*numbers) Expr.new divide: Expr.wrap_varargs(numbers) end |
#do_(*expressions) ⇒ Object
A do expression
Reference: FaunaDB Basic Forms
141 142 143 |
# File 'lib/fauna/query.rb', line 141 def do_(*expressions) Expr.new do: Expr.wrap_varargs(expressions) end |
#drop(number, collection) ⇒ Object
A drop expression
Reference: FaunaDB Collections
248 249 250 |
# File 'lib/fauna/query.rb', line 248 def drop(number, collection) Expr.new drop: Expr.wrap(number), collection: Expr.wrap(collection) end |
#epoch(number, unit) ⇒ Object
An epoch expression
Reference: FaunaDB Time Functions
543 544 545 |
# File 'lib/fauna/query.rb', line 543 def epoch(number, unit) Expr.new epoch: Expr.wrap(number), unit: Expr.wrap(unit) end |
#equals(*values) ⇒ Object
An equals function
Reference: FaunaDB Miscellaneous Functions
675 676 677 |
# File 'lib/fauna/query.rb', line 675 def equals(*values) Expr.new equals: Expr.wrap_varargs(values) end |
#events(ref_set) ⇒ Object
An events expression
Reference: FaunaDB Sets
406 407 408 |
# File 'lib/fauna/query.rb', line 406 def events(ref_set) Expr.new events: Expr.wrap(ref_set) end |
#exists(ref, params = {}) ⇒ Object
An exists expression
Reference: FaunaDB Read functions
298 299 300 |
# File 'lib/fauna/query.rb', line 298 def exists(ref, params = {}) Expr.new Expr.wrap_values(params).merge(exists: Expr.wrap(ref)) end |
#filter(collection, lambda_expr = nil, &lambda_block) ⇒ Object
A filter expression
Only one of lambda_expr or lambda_block should be provided. For example: Fauna.query { filter(collection) { |a| equals a, 1 } }.
Reference: FaunaDB Collections
232 233 234 |
# File 'lib/fauna/query.rb', line 232 def filter(collection, lambda_expr = nil, &lambda_block) Expr.new filter: Expr.wrap(lambda_expr || lambda_block), collection: Expr.wrap(collection) end |
#foreach(collection, lambda_expr = nil, &lambda_block) ⇒ Object
A foreach expression
Only one of lambda_expr or lambda_block should be provided. For example: Fauna.query { foreach(collection) { |a| delete a } }.
Reference: FaunaDB Collections
221 222 223 |
# File 'lib/fauna/query.rb', line 221 def foreach(collection, lambda_expr = nil, &lambda_block) Expr.new foreach: Expr.wrap(lambda_expr || lambda_block), collection: Expr.wrap(collection) end |
#function(name, scope = nil) ⇒ Object
A function function
Reference: FaunaDB Miscellaneous Functions
609 610 611 612 613 |
# File 'lib/fauna/query.rb', line 609 def function(name, scope = nil) return Expr.new function: Expr.wrap(name) if scope.nil? Expr.new function: Expr.wrap(name), scope: Expr.wrap(scope) end |
#functions(scope = nil) ⇒ Object
A functions function
Reference: FaunaDB Miscellaneous Functions
643 644 645 |
# File 'lib/fauna/query.rb', line 643 def functions(scope = nil) Expr.new functions: Expr.wrap(scope) end |
#get(ref, params = {}) ⇒ Object
A get expression
Reference: FaunaDB Read functions
274 275 276 |
# File 'lib/fauna/query.rb', line 274 def get(ref, params = {}) Expr.new Expr.wrap_values(params).merge(get: Expr.wrap(ref)) end |
#gt(*values) ⇒ Object
A greater than function
Reference: FaunaDB Miscellaneous Functions
763 764 765 |
# File 'lib/fauna/query.rb', line 763 def gt(*values) Expr.new gt: Expr.wrap_varargs(values) end |
#gte(*values) ⇒ Object
A greater than or equal function
Reference: FaunaDB Miscellaneous Functions
771 772 773 |
# File 'lib/fauna/query.rb', line 771 def gte(*values) Expr.new gte: Expr.wrap_varargs(values) end |
#has_identity ⇒ Object
A has_identity function
Reference: FaunaDB Authentication
499 500 501 |
# File 'lib/fauna/query.rb', line 499 def has_identity Expr.new has_identity: nil end |
#identify(ref, password) ⇒ Object
An identify function
Reference: FaunaDB Authentication
483 484 485 |
# File 'lib/fauna/query.rb', line 483 def identify(ref, password) Expr.new identify: Expr.wrap(ref), password: Expr.wrap(password) end |
#identity ⇒ Object
An identity function
Reference: FaunaDB Authentication
491 492 493 |
# File 'lib/fauna/query.rb', line 491 def identity Expr.new identity: nil end |
#if_(condition, then_, else_) ⇒ Object
An if expression
Reference: FaunaDB Basic Forms
133 134 135 |
# File 'lib/fauna/query.rb', line 133 def if_(condition, then_, else_) Expr.new if: Expr.wrap(condition), then: Expr.wrap(then_), else: Expr.wrap(else_) end |
#index(name, scope = nil) ⇒ Object
An index function
Reference: FaunaDB Miscellaneous Functions
599 600 601 602 603 |
# File 'lib/fauna/query.rb', line 599 def index(name, scope = nil) return Expr.new index: Expr.wrap(name) if scope.nil? Expr.new index: Expr.wrap(name), scope: Expr.wrap(scope) end |
#indexes(scope = nil) ⇒ Object
An indexes function
Reference: FaunaDB Miscellaneous Functions
635 636 637 |
# File 'lib/fauna/query.rb', line 635 def indexes(scope = nil) Expr.new indexes: Expr.wrap(scope) end |
#insert(ref, ts, action, params) ⇒ Object
An insert expression
Reference: FaunaDB Write functions
340 341 342 |
# File 'lib/fauna/query.rb', line 340 def insert(ref, ts, action, params) Expr.new insert: Expr.wrap(ref), ts: Expr.wrap(ts), action: Expr.wrap(action), params: Expr.wrap(params) end |
#intersection(*sets) ⇒ Object
An intersection expression
Reference: FaunaDB Sets
430 431 432 |
# File 'lib/fauna/query.rb', line 430 def intersection(*sets) Expr.new intersection: Expr.wrap_varargs(sets) end |
#join(source, target_expr = nil, &target_block) ⇒ Object
A join expression
Only one of target_expr or target_block should be provided. For example: Fauna.query { join(source) { |x| match some_index, x } }.
Reference: FaunaDB Sets
457 458 459 |
# File 'lib/fauna/query.rb', line 457 def join(source, target_expr = nil, &target_block) Expr.new join: Expr.wrap(source), with: Expr.wrap(target_expr || target_block) end |
#key_from_secret(secret) ⇒ Object
A key_from_secret expression
Reference: FaunaDB Read functions
282 283 284 |
# File 'lib/fauna/query.rb', line 282 def key_from_secret(secret) Expr.new key_from_secret: Expr.wrap(secret) end |
#keys(scope = nil) ⇒ Object
A keys function
Reference: FaunaDB Miscellaneous Functions
659 660 661 |
# File 'lib/fauna/query.rb', line 659 def keys(scope = nil) Expr.new keys: Expr.wrap(scope) end |
#lambda(&block) ⇒ Object
A lambda expression
Reference: FaunaDB Basic Forms
This form generates #var objects for you, and is called like:
Query.lambda do |a|
Query.add a, a
end
# Produces: {lambda: :a, expr: {add: [{var: :a}, {var: :a}]}}
Query functions requiring lambdas can be passed blocks without explicitly calling #lambda.
You can also use #lambda_expr and #var directly.
block-
Takes one or more #var expressions and uses them to construct an expression. If this takes more than one argument, the lambda destructures an array argument. (To destructure single-element arrays use #lambda_expr.)
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/fauna/query.rb', line 164 def lambda(&block) dsl = Query::QueryDSLContext.new vars = block.parameters.map do |kind, name| fail ArgumentError, 'Splat parameters are not supported in lambda expressions.' if kind == :rest name end case vars.length when 0 fail ArgumentError, 'Block must take at least 1 argument.' when 1 # When there's only 1 parameter, don't use an array pattern. lambda_expr vars[0], DSLContext.eval_dsl(dsl, var(vars[0]), &block) else lambda_expr vars, DSLContext.eval_dsl(dsl, *(vars.map { |v| var(v) }), &block) end end |
#lambda_expr(var, expr) ⇒ Object
189 190 191 |
# File 'lib/fauna/query.rb', line 189 def lambda_expr(var, expr) Expr.new lambda: Expr.wrap(var), expr: Expr.wrap(expr) end |
#let(vars, expr = nil, &block) ⇒ Object
A let expression
Only one of expr or block should be provided.
Block example: Fauna.query { let(x: 2) { add(1, x) } }.
Expression example: Fauna.query { let({ x: 2 }, add(1, var(:x))) }.
Reference: FaunaDB Basic Forms
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/fauna/query.rb', line 103 def let(vars, expr = nil, &block) in_ = if block.nil? expr else dsl = QueryDSLContext.new dslcls = (class << dsl; self; end) vars.keys.each do |v| dslcls.send(:define_method, v) { var(v) } end DSLContext.eval_dsl(dsl, &block) end Expr.new let: Expr.wrap_values(vars), in: Expr.wrap(in_) end |
#login(ref, params) ⇒ Object
A login function
Reference: FaunaDB Authentication
467 468 469 |
# File 'lib/fauna/query.rb', line 467 def login(ref, params) Expr.new login: Expr.wrap(ref), params: Expr.wrap(params) end |
#logout(all_tokens) ⇒ Object
A logout function
Reference: FaunaDB Authentication
475 476 477 |
# File 'lib/fauna/query.rb', line 475 def logout(all_tokens) Expr.new logout: Expr.wrap(all_tokens) end |
#lt(*values) ⇒ Object
A less than function
Reference: FaunaDB Miscellaneous Functions
747 748 749 |
# File 'lib/fauna/query.rb', line 747 def lt(*values) Expr.new lt: Expr.wrap_varargs(values) end |
#lte(*values) ⇒ Object
A less than or equal function
Reference: FaunaDB Miscellaneous Functions
755 756 757 |
# File 'lib/fauna/query.rb', line 755 def lte(*values) Expr.new lte: Expr.wrap_varargs(values) end |
#map(collection, lambda_expr = nil, &lambda_block) ⇒ Object
A map expression
Only one of lambda_expr or lambda_block should be provided. For example: Fauna.query { map(collection) { |a| add a, 1 } }.
Reference: FaunaDB Collections
210 211 212 |
# File 'lib/fauna/query.rb', line 210 def map(collection, lambda_expr = nil, &lambda_block) Expr.new map: Expr.wrap(lambda_expr || lambda_block), collection: Expr.wrap(collection) end |
#match(index, *terms) ⇒ Object
A match expression
Reference: FaunaDB Sets
414 415 416 |
# File 'lib/fauna/query.rb', line 414 def match(index, *terms) Expr.new match: Expr.wrap(index), terms: Expr.wrap_varargs(terms) end |
#modulo(*numbers) ⇒ Object
A modulo function
Reference: FaunaDB Miscellaneous Functions
739 740 741 |
# File 'lib/fauna/query.rb', line 739 def modulo(*numbers) Expr.new modulo: Expr.wrap_varargs(numbers) end |
#multiply(*numbers) ⇒ Object
A multiply function
Reference: FaunaDB Miscellaneous Functions
715 716 717 |
# File 'lib/fauna/query.rb', line 715 def multiply(*numbers) Expr.new multiply: Expr.wrap_varargs(numbers) end |
#new_id ⇒ Object
A new_id function
Reference: FaunaDB Miscellaneous Functions
571 572 573 |
# File 'lib/fauna/query.rb', line 571 def new_id Expr.new new_id: nil end |
#next_id ⇒ Object
A next_id function
Reference: FaunaDB Miscellaneous Functions
561 562 563 |
# File 'lib/fauna/query.rb', line 561 def next_id Expr.new next_id: nil end |
#not_(boolean) ⇒ Object
A not function
Reference: FaunaDB Miscellaneous Functions
795 796 797 |
# File 'lib/fauna/query.rb', line 795 def not_(boolean) Expr.new not: Expr.wrap(boolean) end |
#object(fields) ⇒ Object
An object expression
Query expression constructs can also take a regular ruby object, so the following are equivalent:
Fauna.query { { x: 1, y: add(1, 2) } }
Fauna.query { object(x: 1, y: add(1, 2)) }
Reference: FaunaDB Basic Forms
71 72 73 |
# File 'lib/fauna/query.rb', line 71 def object(fields) Expr.new object: Expr.wrap_values(fields) end |
#or_(*booleans) ⇒ Object
An or function
Reference: FaunaDB Miscellaneous Functions
787 788 789 |
# File 'lib/fauna/query.rb', line 787 def or_(*booleans) Expr.new or: Expr.wrap_varargs(booleans) end |
#paginate(set, params = {}) ⇒ Object
A paginate expression
Reference: FaunaDB Read functions
290 291 292 |
# File 'lib/fauna/query.rb', line 290 def paginate(set, params = {}) Expr.new Expr.wrap_values(params).merge(paginate: Expr.wrap(set)) end |
#prepend(collection, elements) ⇒ Object
A prepend expression
Reference: FaunaDB Collections
256 257 258 |
# File 'lib/fauna/query.rb', line 256 def prepend(collection, elements) Expr.new prepend: Expr.wrap(elements), collection: Expr.wrap(collection) end |
#query(expr) ⇒ Object
A query expression
Reference: FaunaDB Basic Forms
79 80 81 |
# File 'lib/fauna/query.rb', line 79 def query(expr) Expr.new query: Expr.wrap(expr) end |
#ref(str, id = nil) ⇒ Object
Construct a ref value
Reference: FaunaDB Values
46 47 48 49 50 51 52 |
# File 'lib/fauna/query.rb', line 46 def ref(str, id = nil) if id.nil? Expr.new :@ref => Expr.wrap(str) else Expr.new ref: Expr.wrap(str), id: Expr.wrap(id) end end |
#remove(ref, ts, action) ⇒ Object
A remove expression
Reference: FaunaDB Write functions
348 349 350 |
# File 'lib/fauna/query.rb', line 348 def remove(ref, ts, action) Expr.new remove: Expr.wrap(ref), ts: Expr.wrap(ts), action: Expr.wrap(action) end |
#replace(ref, params) ⇒ Object
A replace expression
Reference: FaunaDB Write functions
324 325 326 |
# File 'lib/fauna/query.rb', line 324 def replace(ref, params) Expr.new replace: Expr.wrap(ref), params: Expr.wrap(params) end |
#select(path, from, params = {}) ⇒ Object
A select function
Reference: FaunaDB Miscellaneous Functions
691 692 693 |
# File 'lib/fauna/query.rb', line 691 def select(path, from, params = {}) Expr.new Expr.wrap_values(params).merge(select: Expr.wrap(path), from: Expr.wrap(from)) end |
#select_all(path, from) ⇒ Object
A select_all function
Reference: FaunaDB Miscellaneous Functions
699 700 701 |
# File 'lib/fauna/query.rb', line 699 def select_all(path, from) Expr.new select_all: Expr.wrap(path), from: Expr.wrap(from) end |
#singleton(ref) ⇒ Object
A singleton expression
Reference: FaunaDB Sets
398 399 400 |
# File 'lib/fauna/query.rb', line 398 def singleton(ref) Expr.new singleton: Expr.wrap(ref) end |
#subtract(*numbers) ⇒ Object
A subtract function
Reference: FaunaDB Miscellaneous Functions
723 724 725 |
# File 'lib/fauna/query.rb', line 723 def subtract(*numbers) Expr.new subtract: Expr.wrap_varargs(numbers) end |
#take(number, collection) ⇒ Object
A take expression
Reference: FaunaDB Collections
240 241 242 |
# File 'lib/fauna/query.rb', line 240 def take(number, collection) Expr.new take: Expr.wrap(number), collection: Expr.wrap(collection) end |
#time(string) ⇒ Object
A time expression
Reference: FaunaDB Time Functions
535 536 537 |
# File 'lib/fauna/query.rb', line 535 def time(string) Expr.new time: Expr.wrap(string) end |
#tokens(scope = nil) ⇒ Object
A tokens function
Reference: FaunaDB Miscellaneous Functions
651 652 653 |
# File 'lib/fauna/query.rb', line 651 def tokens(scope = nil) Expr.new tokens: Expr.wrap(scope) end |
#union(*sets) ⇒ Object
A union expression
Reference: FaunaDB Sets
422 423 424 |
# File 'lib/fauna/query.rb', line 422 def union(*sets) Expr.new union: Expr.wrap_varargs(sets) end |
#update(ref, params) ⇒ Object
An update expression
Reference: FaunaDB Write functions
316 317 318 |
# File 'lib/fauna/query.rb', line 316 def update(ref, params) Expr.new update: Expr.wrap(ref), params: Expr.wrap(params) end |
#var(name) ⇒ Object
A var expression
Reference: FaunaDB Basic Forms
125 126 127 |
# File 'lib/fauna/query.rb', line 125 def var(name) Expr.new var: Expr.wrap(name) end |