module Granite::Querying
Direct including types
Defined in:
granite/querying.crInstance Method Summary
-
#all(clause = "", params = [] of Granite::Columns::Type)
All will return all rows in the database.
-
#count : Int32
count returns a count of all the records
- #exec(clause = "")
-
#exists?(id : Number | String | Nil) : Bool
Returns
true
if a records exists with a PK of id, otherwisefalse
. -
#exists?(criteria : Granite::ModelArgs) : Bool
Returns
true
if a records exists that matches criteria, otherwisefalse
. -
#exists?(**criteria : Granite::Columns::Type) : Bool
Returns
true
if a records exists that matches criteria, otherwisefalse
. -
#find(value)
find returns the row with the primary key specified.
-
#find!(value)
find returns the row with the primary key specified.
-
#find_by(criteria : Granite::ModelArgs)
Returns the first row found that matches criteria.
-
#find_by(**criteria : Granite::Columns::Type)
Returns the first row found that matches criteria.
-
#find_by!(criteria : Granite::ModelArgs)
Returns the first row found that matches criteria.
-
#find_by!(**criteria : Granite::Columns::Type)
Returns the first row found that matches criteria.
- #find_each(clause = "", params = [] of Granite::Columns::Type, batch_size limit = 100, offset = 0, &)
- #find_in_batches(clause = "", params = [] of Granite::Columns::Type, batch_size limit = 100, offset = 0, &)
-
#first(clause = "", params = [] of Granite::Columns::Type)
First adds a
LIMIT 1
clause to the query and returns the first result - #first!(clause = "", params = [] of Granite::Columns::Type)
-
#from_rs(result : DB::ResultSet) : self
Entrypoint for creating a new object from a result set.
- #query(clause = "", params = [] of Granite::Columns::Type, &)
- #raw_all(clause = "", params = [] of Granite::Columns::Type)
- #scalar(clause = "", &)
Instance Method Detail
All will return all rows in the database. The clause allows you to specify a WHERE, JOIN, GROUP BY, ORDER BY and any other SQL92 compatible query to your table. The result will be a Collection(Model) object which lazy loads an array of instantiated instances of your Model class. This allows you to take full advantage of the database that you are using so you are not restricted or dummied down to support a DSL. Lazy load prevent running unnecessary queries from unused variables.
Returns true
if a records exists with a PK of id, otherwise false
.
Returns true
if a records exists that matches criteria, otherwise false
.
Returns true
if a records exists that matches criteria, otherwise false
.
find returns the row with the primary key specified. Otherwise raises an exception.
Returns the first row found that matches criteria. Otherwise nil
.
Returns the first row found that matches criteria. Otherwise nil
.
Returns the first row found that matches criteria. Otherwise raises a NotFound
exception.
Returns the first row found that matches criteria. Otherwise raises a NotFound
exception.
First adds a LIMIT 1
clause to the query and returns the first result
Entrypoint for creating a new object from a result set.