module

Granite::Querying::ClassMethods

Instance methods

all(clause = "", params = [] of Granite::Columns::Type, use_primary_adapter = true)

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.

Source
count

count returns a count of all the records

Source
exec(clause = "")
Source
exists?(id : Number | String | Nil) : Bool

Returns true if a records exists with a PK of id, otherwise false.

Source
exists?(criteria : Granite::ModelArgs) : Bool

Returns true if a records exists that matches criteria, otherwise false.

Source
exists?

Returns true if a records exists that matches criteria, otherwise false.

Source
find(value)

find returns the row with the primary key specified. Otherwise nil.

Source
find!(value)

find returns the row with the primary key specified. Otherwise raises an exception.

Source
find_by(criteria : Granite::ModelArgs)

Returns the first row found that matches criteria. Otherwise nil.

Source
find_by

Returns the first row found that matches criteria. Otherwise nil.

Source
find_by!(criteria : Granite::ModelArgs)

Returns the first row found that matches criteria. Otherwise raises a NotFound exception.

Source
find_by!

Returns the first row found that matches criteria. Otherwise raises a NotFound exception.

Source
find_each(clause = "", params = [] of Granite::Columns::Type, batch_size limit = 100, offset = 0, &)
Source
find_in_batches(clause = "", params = [] of Granite::Columns::Type, batch_size limit = 100, offset = 0, &)
Source
first(clause = "", params = [] of Granite::Columns::Type)

First adds a LIMIT 1 clause to the query and returns the first result

Source
first!(clause = "", params = [] of Granite::Columns::Type)
Source
from_rs(result : DB::ResultSet) : self

Entrypoint for creating a new object from a result set.

Source
query(clause = "", params = [] of Granite::Columns::Type, &)
Source
raw_all(clause = "", params = [] of Granite::Columns::Type)
Source
scalar(clause = "", &)
Source