class Jennifer::QueryBuilder::ModelQuery(T)

Defined in:

jennifer/query_builder/model_query.cr

Constructors

Instance Method Summary

Instance methods inherited from class Jennifer::QueryBuilder::IModelQuery

clone clone, destroy destroy, find(id) find, find!(id) find!, find_each(batch_size : Int32 = 1000, start = nil, direction : String | Symbol = "asc", &) find_each, find_in_batches(batch_size : Int32 = 1000, start = nil, direction : String | Symbol = "asc", &) find_in_batches, model_class model_class, patch(options : Hash | NamedTuple)
patch(**opts)
patch
, patch!(options : Hash | NamedTuple)
patch!(**opts)
patch!
, relation(name, type = :left) relation, table table

Instance methods inherited from module Jennifer::QueryBuilder::EagerLoading

_select_fields : Array(Criteria) _select_fields, eager_load(*names, **deep_relations) eager_load, includes(*names, **deep_relations) includes, multi_query_relation_tree multi_query_relation_tree, nested_relation_tree : NestedRelationTree nested_relation_tree, preload(*names, **deep_relations) preload, with_relation(names : Array)
with_relation(*names)
with_relation

Instance methods inherited from class Jennifer::QueryBuilder::Query

_select_fields : Array(Criteria) _select_fields, adapter : Adapter::Base adapter, as_sql(generator)
as_sql
as_sql
, clone clone, distinct distinct, do_nothing? : Bool do_nothing?, empty? empty?, eql?(other : Query)
eql?(other : Statement | LogicOperator)
eql?
, except(parts : Array(String)) except, exec(&) exec, expression_builder : Jennifer::QueryBuilder::ExpressionBuilder expression_builder, filterable? filterable?, from(from : String | Query) from, group(column : String)
group(column : Symbol)
group(column : Criteria)
group(*columns : String)
group(*columns : Symbol)
group(&)
group
, having(&) having, limit(count : Int32) limit, lock(type : String | Bool = true) lock, merge(other : self) merge, none none, offset(count : Int32) offset, select(raw_sql : String)
select(field : Criteria)
select(fields : Array(Criteria))
select(*fields : Symbol)
select(&)
select
, set_tree(other : LogicOperator | Condition)
set_tree(other : Query)
set_tree(other : SQLNode)
set_tree(other : Nil)
set_tree
, sql_args : Array(DBAny) sql_args, table : String table, to_json(only : Array(String)? = nil, except : Array(String)? = nil, &)
to_json(json : JSON::Builder)
to_json(json : JSON::Builder, only : Array(String)? = nil, except : Array(String)? = nil, &)
to_json(only : Array(String)? = nil, except : Array(String)? = nil)
to_json
, to_s(io : IO) to_s, tree : Condition | LogicOperator | Nil tree, tree=(tree : Condition | LogicOperator | Nil) tree=, union(query, all : Bool = false) union, where(&)
where(conditions : Hash(Symbol, _))
where
, with(name : String | Symbol, query : Query, recursive : Bool = false) with

Constructor methods inherited from class Jennifer::QueryBuilder::Query

new(table, adapter = Adapter.default_adapter)
new
new

Class methods inherited from class Jennifer::QueryBuilder::Query

[](*args) [], build(*args) build, null(table = "") null

Instance methods inherited from module Jennifer::QueryBuilder::Executables

db_results : Array(Hash(String, DBAny)) db_results, decrement(fields : Hash(Symbol, _))
decrement(**fields)
decrement
, delete delete, each(&) each, each_result_set(&) each_result_set, exists? : Bool exists?, explain : String explain, find_each(primary_key : String, batch_size : Int32 = 1000, start = nil, direction : String | Symbol = "asc", &)
find_each(primary_key : Criteria, batch_size : Int32 = 1000, start = nil, direction : String | Symbol = "asc", &)
find_each(primary_key : Nil, batch_size : Int32 = 1000, start : Int32 = 0, direction : String | Symbol = "asc", &)
find_each(batch_size : Int32 = 1000, start : Int32 = 0, direction : String | Symbol = "asc", &)
find_each
, find_in_batches(primary_key : String, batch_size : Int32 = 1000, start : Int32? = nil, direction : String | Symbol = "asc", &)
find_in_batches(batch_size : Int32 = 1000, start : Int32 = 0, &)
find_in_batches(primary_key : Criteria, batch_size : Int32 = 1000, start = nil, direction : String | Symbol = "asc", &)
find_in_batches(primary_key : Nil, batch_size : Int32 = 1000, start : Int32 = 0, &)
find_in_batches
, find_records_by_sql(query : String, args : Array(DBAny) = [] of DBAny) find_records_by_sql, first first, first! first!, ids ids, increment(fields : Hash(Symbol, _))
increment(**fields)
increment
, insert(fields : Array(String), values : Array(Array(DBAny)))
insert(options : Hash(String | Symbol, DBAny) | NamedTuple)
insert
, last last, last! last!, pluck(fields : Array) : Array(Array(DBAny))
pluck(field : String | Symbol) : Array(DBAny)
pluck(*fields : String | Symbol) : Array(Array(DBAny))
pluck(**types : **T) forall T
pluck
, results : Array(Record) results, to_a to_a, update(&)
update(options : Hash)
update(**options)
update
, upsert(fields : Array(String), values : Array(Array(DBAny)), unique_fields : Array = [] of String)
upsert(fields : Array(String), values : Array(Array(DBAny)), unique_fields : Array, &)
upsert

Instance methods inherited from module Jennifer::QueryBuilder::Joining

join(source : Class, table_alias : String? = nil, type = :inner, relation : String? = nil, &)
join(source : String, table_alias : String? = nil, type = :inner, relation : String? = nil, &)
join(source : Query, table_alias : String, type = :inner, &)
join
, lateral_join(source : Query, table_alias : String, type = :inner, &) lateral_join, left_join(source : Class, table_alias : String? = nil, &)
left_join(source : String, table_alias : String? = nil, &)
left_join
, right_join(source : Class, table_alias : String? = nil, &)
right_join(source : String, table_alias : String? = nil, &)
right_join

Instance methods inherited from module Jennifer::QueryBuilder::Ordering

order(opts : Hash(String, String | Symbol))
order(opts : Hash(Symbol, String | Symbol))
order(opt : OrderExpression)
order(opts : Array(OrderExpression))
order(opts : Hash(String | Symbol, String | Symbol))
order(**opts)
order(&)
order
, ordered? ordered?, reorder(opts : Hash(String, String | Symbol))
reorder(opts : Hash(Symbol, String | Symbol))
reorder(opt : OrderExpression)
reorder(opts : Array(OrderExpression))
reorder(opts : Hash(String | Symbol, String | Symbol))
reorder(**opts)
reorder(&)
reorder

Instance methods inherited from module Jennifer::QueryBuilder::Aggregations

avg(field, klass : T.class) : T forall T avg, count : Int32 count, group_avg(field, klass : T.class) : Array(T) forall T group_avg, group_count(field) group_count, group_max(field, klass : T.class) : Array(T) forall T group_max, group_min(field, klass : T.class) : Array(T) forall T group_min, group_sum(field, klass : T.class) : Array(T) forall T group_sum, max(field, klass : T.class) : T forall T max, min(field, klass : T.class) : T forall T min, sum(field, klass : T.class) : T forall T sum

Instance methods inherited from module Jennifer::QueryBuilder::Statement

as_sql(sql_generator) as_sql, filterable? filterable?, sql_args : Array(DBAny) sql_args

Constructor Detail

def self.new(table, adapter) #

[View source]
def self.new #

[View source]

Instance Method Detail

def clone #
Description copied from class Jennifer::QueryBuilder::IModelQuery

NOTE can't be abstract because is already implemented by super class.


[View source]
def find_by_sql(query : String, args : Array(DBAny) = [] of DBAny) #

Perform search using given plain query and arguments and builds ` but also allow to preload related records using #preload method nad respects #none


[View source]
def model_class #
Description copied from class Jennifer::QueryBuilder::IModelQuery

NOTE improperly detects source of #abstract_class if run sam with only Version model


[View source]
def multi_query_relation_tree #

[View source]
def nested_relation_tree : NestedRelationTree #

[View source]
def to_a #

Executes request and maps result set to objects with loading any requested related objects


[View source]