module Avram::Queryable(T)
Included Modules
- Enumerable(T)
Defined in:
avram/queryable.crInstance Method Summary
- #add_preload(&block : Array(T) -> Nil)
-
#any? : Bool
Returns
true
if at least one of the collection's members is truthy. - #cache_key(operation : Symbol) : String
- #cache_key : String
- #cache_store
- #database(*args, **options)
- #database(*args, **options, &)
-
#delete : Int64
Delete the records using the query's where clauses, or all records if no wheres are added.
- #distinct : self
- #distinct_on(&) : self
-
#each(&)
Must yield this collection's elements to the block.
- #exec_scalar(&)
-
#first : T
Returns the first element in the collection.
-
#first? : T | Nil
Returns the first element in the collection.
- #group(&) : self
- #group_count : Hash(Array(PGValue), Int64)
- #join(join_clause : Avram::Join::SqlClause) : self
- #last : T
- #last? : T | Nil
- #limit(amount) : self
- #merge_query(query_to_merge : Avram::QueryBuilder) : self
- #none : self
-
#none? : Bool
Returns
true
if all of the elements of the collection are falsey. - #offset(amount) : self
-
#or(&) : self
Run the
#or
block first to grab the last WHERE clause and set its conjunction to OR. - #order_by(column, direction) : self
- #order_by(order : Avram::OrderByClause) : self
- #preloads
- #primary_key_name(*args, **options)
- #primary_key_name(*args, **options, &)
- #query : Avram::QueryBuilder
- #query=(query : Avram::QueryBuilder)
- #random_order : self
- #reset_limit : self
- #reset_offset : self
- #reset_order : self
- #reset_where(&) : self
- #results : Array(T)
- #schema_class : T.class
- #select_count : Int64
- #table_name(*args, **options)
- #table_name(*args, **options, &)
- #to_prepared_sql
- #to_sql
-
#update : Int64
Update the records using the query's where clauses, or all records if no wheres are added.
- #where(column : Symbol, value) : self
- #where(sql_clause : Avram::Where::SqlClause) : self
- #where(statement : String, *bind_vars) : self
- #where(statement : String, *, args bind_vars : Array) : self
- #where(&) : self
Instance Method Detail
Returns true
if at least one of the collection's members is truthy.
[nil, true, 99].any? # => true
[nil, false].any? # => false
Delete the records using the query's where clauses, or all records if no wheres are added.
Returns the number of deleted records as Int64
.
# DELETE FROM users WHERE age < 21
UserQuery.new.age.lt(21).delete
Must yield this collection's elements to the block.
Returns the first element in the collection. Raises Enumerable::EmptyError
if the collection is empty.
([1, 2, 3]).first # => 1
([] of Int32).first # raises Enumerable::EmptyError
Returns the first element in the collection.
When the collection is empty, returns nil
.
([1, 2, 3]).first? # => 1
([] of Int32).first? # => nil
Returns true
if all of the elements of the collection are falsey.
[nil, false].none? # => true
[nil, false, true].none? # => false
It's the opposite of all?
.
Run the #or
block first to grab the last WHERE clause and set its
conjunction to OR. Then call yield to set the next set of ORs
Update the records using the query's where clauses, or all records if no wheres are added.
Returns the number of records updated as Int64
.
# Update all comments with the word "spam" as spam
CommentQuery.new.body.ilike("spam").update(spam: true)