module Ktistec::Model::ClassMethods

Defined in:

framework/model.cr

Instance Method Summary

Instance Method Detail

def all(include_deleted : Bool = false, include_undone : Bool = false) #

Returns all instances.


[View source]
def all_subtypes #

Returns type and all subtypes.


[View source]
def columns(prefix = nil) #

Returns table columns in format suitable for building queries.


[View source]
def conditions(*terms, include_deleted : Bool = false, include_undone : Bool = false, options : Hash(String, Any) | Nil = nil, **options_) forall Any #

[View source]
def count(options : Hash(String, Any), include_deleted : Bool = false, include_undone : Bool = false) forall Any #

Returns the count of saved instances.


[View source]
def count(include_deleted : Bool = false, include_undone : Bool = false, **options) #

Returns the count of saved instances.


[View source]
def empty? #

Returns true if no instances exist.


[View source]
def exec(query : String, args : Array | Nil = nil) #

Runs the query.

Returns the number of rows affected.


[View source]
def exec(query : String, *args_) #

Runs the query.

Returns the number of rows affected.


[View source]
def find(_id id : Int | Nil, include_deleted : Bool = false, include_undone : Bool = false) #

Finds the saved instance.

Raises NotFound if no such saved instance exists.


[View source]
def find(options : Hash(String, Any), include_deleted : Bool = false, include_undone : Bool = false) forall Any #

Finds the saved instance.

Raises NotFound if no such saved instance exists.


[View source]
def find(include_deleted : Bool = false, include_undone : Bool = false, **options) #

Finds the saved instance.

Raises NotFound if no such saved instance exists.


[View source]
def find?(_id id : Int | Nil, include_deleted : Bool = false, include_undone : Bool = false) #

Finds the saved instance.

Returns nil if no such saved instance exists.


[View source]
def find?(options : Hash(String, Any), include_deleted : Bool = false, include_undone : Bool = false) forall Any #

Finds the saved instance.

Returns nil if no such saved instance exists.


[View source]
def find?(include_deleted : Bool = false, include_undone : Bool = false, **options) #

Finds the saved instance.

Returns nil if no such saved instance exists.


[View source]
def find_or_create(options : Hash(String, Any), include_deleted : Bool = false, include_undone : Bool = false, skip_validation : Bool = false, skip_associated : Bool = false) forall Any #

Finds an existing instance, or instantiates and saves a new instance.


[View source]
def find_or_create(include_deleted : Bool = false, include_undone : Bool = false, skip_validation : Bool = false, skip_associated : Bool = false, **options) #

Finds an existing instance, or instantiates and saves a new instance.


[View source]
def find_or_new(options : Hash(String, Any), include_deleted : Bool = false, include_undone : Bool = false) forall Any #

Finds an existing instance or instantiates a new instance.


[View source]
def find_or_new(include_deleted : Bool = false, include_undone : Bool = false, **options) #

Finds an existing instance or instantiates a new instance.


[View source]
def persistent_columns #

[View source]
def scalar(query : String, args : Array | Nil = nil) #

Runs the query.

Returns the result.


[View source]
def scalar(query : String, *args_) #

Runs the query.

Returns the result.


[View source]
def sql(query : String, *arguments) #

Runs the query.

Returns saved instances.


[View source]
def table(as_name = nil) #

Returns table name in format suitable for building queries.


[View source]
def table_name #

Returns the table name.


[View source]
def values(options : Hash(String, Any) | Nil = nil, **options_) forall Any #

[View source]
def where(options : Hash(String, Any), include_deleted : Bool = false, include_undone : Bool = false) forall Any #

Returns saved instances.


[View source]
def where(where : String, *arguments, include_deleted : Bool = false, include_undone : Bool = false) #

Returns saved instances.


[View source]
def where(include_deleted : Bool = false, include_undone : Bool = false, **options) #

Returns saved instances.


[View source]