module Avram::Queryable(T)

Included Modules

Defined in:

avram/queryable.cr

Instance Method Summary

Instance Method Detail

def add_preload(&block : Array(T) -> Nil) #

[View source]
def clone : self #

[View source]
def delete : Int64 #

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

[View source]
def distinct : self #

[View source]
def distinct_on(&) : self #

[View source]
def each(&) #
Description copied from module Enumerable(T)

Must yield this collection's elements to the block.


[View source]
def exec_scalar #

[View source]
def find(id) #

[View source]
def first #
Description copied from module Enumerable(T)

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

[View source]
def first? #
Description copied from module Enumerable(T)

Returns the first element in the collection. When the collection is empty, returns nil.

([1, 2, 3]).first?   # => 1
([] of Int32).first? # => nil

[View source]
def group(&) : self #

[View source]
abstract def id #

[View source]
def join(join_clause : Avram::Join::SqlClause) : self #

[View source]
def last #

[View source]
def last? #

[View source]
def limit(amount) : self #

[View source]
def none : self #

[View source]
def offset(amount) : self #

[View source]
def order_by(column, direction) : self #

[View source]
def preloads #

[View source]
def query #

[View source]
def query=(query) #

[View source]
def reset_limit : self #

[View source]
def reset_offset : self #

[View source]
def reset_order : self #

[View source]
def reset_where(&) : self #

[View source]
def results : Array(T) #

[View source]
def select_count : Int64 #

[View source]
def to_prepared_sql #

[View source]
def to_sql #

[View source]
abstract def update : Int64 #

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)

[View source]
def where(column : Symbol, value) : self #

[View source]
def where(statement : String, *bind_vars) : self #

[View source]
def where(statement : String, *, args bind_vars : Array) : self #

[View source]