module Sandstone::ORM::Querying

Defined in:

sandstone/querying.cr

Instance Method Summary

Macro Summary

Instance Method Detail

def all(clause = "", params = [] of DB::Any) #

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 results will be 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.


[View source]
def clear #

Clear is used to remove all rows from the table and reset the counter for the primary key.


[View source]
def exec(clause = "") #

[View source]
def find(value) #

find returns the row with the primary key specified. it checks by primary by default, but one can pass another field for comparison


[View source]
def find_by(field : Symbol, value) #

find_by using symbol for field name.


[View source]
def find_by(field : String, value) #

find_by returns the first row found where the field maches the value


[View source]
def find_collection(values) #

[View source]
def find_collection_by(field : Symbol, values) #

[View source]
def find_collection_by(field : String, values) #

[View source]
def find_each(clause = "", params = [] of DB::Any, batch_size limit = 100, offset = 0, &) #

[View source]
def find_in_batches(clause = "", params = [] of DB::Any, batch_size limit = 100, offset = 0, &) #

[View source]
def first(clause = "", params = [] of DB::Any) #

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


[View source]
def last(clause = "", params = [] of DB::Any) #

[View source]
def prep_array_for_sql(strings : Array(String)) : String #

[View source]
def prep_array_for_sql(ints : Array(Int64)) : String #

[View source]
def query(clause = "", params = [] of DB::Any, &) #

[View source]
def sanitize_string_for_sql(string : String) : String #

[View source]
def scalar(clause = "", &) #

[View source]

Macro Detail

macro find_or_creatable(class_name, column_name) #

[View source]