module Avram::Queryable(T)
Included Modules
- Enumerable(T)
Defined in:
avram/queryable.crInstance Method Summary
- #add_preload(&block : Array(T) -> Nil)
- #clone : self
-
#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
- #find(id)
-
#first
Returns the first element in the collection.
-
#first?
Returns the first element in the collection.
- #group(&) : self
- #id
- #join(join_clause : Avram::Join::SqlClause) : self
- #last
- #last?
- #limit(amount) : self
- #none : self
- #offset(amount) : self
- #order_by(column, direction) : self
- #preloads
- #query
- #query=(query)
- #reset_limit : self
- #reset_offset : self
- #reset_order : self
- #reset_where(&) : self
- #results : Array(T)
- #select_count : Int64
- #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(statement : String, *bind_vars) : self
- #where(statement : String, *, args bind_vars : Array) : self
Instance Method Detail
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
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)