class Silvio::Database::Client

Included Modules

Extended Modules

Defined in:

silvio/database.cr

Constant Summary

CRECTO_DESTROY_ASSOCIATIONS = Array(Symbol).new
CRECTO_ENUM_FIELDS = [] of NamedTuple(name: Symbol, type: String, column_name: String, column_type: String)
CRECTO_FIELDS = [{name: :name, type: String}, {name: :token, type: String}, {name: :address, type: String}, {name: :network_id, type: PkeyValue}] of NamedTuple(name: Symbol, type: String)
CRECTO_MODEL_FIELDS = [] of NamedTuple(name: Symbol, type: String)
CRECTO_NULLIFY_ASSOCIATIONS = Array(Symbol).new
CRECTO_VALID_FIELD_OPTIONS = [:primary_key, :virtual, :default]
CRECTO_VALID_FIELD_TYPES = [String, Int64, Int32, Int16, Float32, Float64, Bool, Time, Int32 | Int64, Float32 | Float64, Json, PkeyValue, Array(String), Array(Int64), Array(Int32), Array(Int16), Array(Float32), Array(Float64), Array(Bool), Array(Time), Array(Int32 | Int64), Array(Float32 | Float64), Array(Json), Array(PkeyValue)]

macro constants

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(pull : JSON::PullParser) #

def self.new(__temp_88 : DB::ResultSet) #

def self.new #

[View source]

Class Method Detail

def self.add_destroy_association(a) #

[View source]
def self.add_nullify_association(a) #

[View source]
def self.association_type_for_association(association : Symbol) #

Get the association type for the association i.e. :posts => :has_many


def self.cast(attributes : NamedTuple, whitelist : Tuple = attributes.keys) #

[View source]
def self.cast(attributes : Hash(Symbol, T), whitelist : Array(Symbol) = attributes.keys) forall T #

[View source]
def self.cast(attributes : Hash(String, T), whitelist : Array(String) = attributes.keys) forall T #

[View source]
def self.cast(**attributes) #

Class methods for mass assignment


[View source]
def self.cast!(attributes : NamedTuple) #

[View source]
def self.cast!(**attributes : **T) forall T #

Class methods for compile-time type safe mass assignment


[View source]
def self.changeset_fields #

Class method to get the .changeset_fields


[View source]
def self.created_at_field #

[View source]
def self.destroy_associations #

[View source]
def self.fields #

[View source]
def self.foreign_key_for_association(association : Symbol) : Symbol | Nil #

Get the foreign key for the association i.e. :posts => :user_id


def self.foreign_key_for_association(klass : Crecto::Model.class) #

def self.foreign_key_value_for_association(association : Symbol, item) #

Get the foreign key value from the relation object i.e. :posts, post => post.user_id


def self.from_rs(__temp_88 : DB::ResultSet) #

def self.klass_for_association(association : Symbol) #

Get the Class for the assocation name i.e. :posts => Post


def self.nullify_associations #

[View source]
def self.primary_key_field #

Return the primary key field as a String


[View source]
def self.primary_key_field_symbol #

Return the primary key field as a Symbol


[View source]
def self.set_value_for_association(association : Symbol, item, items) #

Set the value for the association i.e. :posts, user, [posts] => user.posts = [posts]


def self.table_name #

Class method to get the table name


[View source]
def self.through_key_for_association(association : Symbol) : Symbol | Nil #

Get the through association symbol i.e. :posts => :user_posts (if has_many through)


def self.updated_at_field #

[View source]
def self.use_primary_key? #

[View source]
def self.validate(message : String, block : Silvio::Database::Client -> _) #

Validates generic block against an instance of the class


Instance Method Detail

def address : String? #

def address! #

def address=(_address : String | Nil) #

def cast(attributes : NamedTuple, whitelist : Tuple = attributes.keys) #

def cast(attributes : Hash(Symbol, T), whitelist : Array(Symbol) = attributes.keys) forall T #

def cast(attributes : Hash(String, T), whitelist : Array(String) = attributes.keys) forall T #

def cast(**attributes : **T) forall T #

Empty instance methods for mass assignment Implementations are in the Schema.setup macro


def cast!(attributes : NamedTuple) #

[View source]
def cast!(**attributes : **T) forall T #

Instance method for compile-time type safe mass assignment


[View source]
def created_at : Time? #

def created_at=(_created_at : Time | Nil) #

def created_at_to_now #

def created_at_value #

def get_changeset #

[View source]
def id : Int16 | Int32 | Int64 | Int8 | String | Nil #

def id=(_id : PkeyValue | Nil) #

def initial_values : Hash(Symbol, DbValue) | Nil #

def initial_values=(initial_values : Hash(Symbol, DbValue) | Nil) #

def name : String? #

def name! #

Builds fields' cast typed method


def name=(_name : String | Nil) #

def network : Network #

[View source]
def network=(val : Network | Nil) #

[View source]
def network? : Network | Nil #

[View source]
def network_id : Int16 | Int32 | Int64 | Int8 | String | Nil #

def network_id! #

def network_id=(_network_id : PkeyValue | Nil) #

def pkey_value #

Returns the value of the primary key field


def to_query_hash(include_virtual = false) #

Builds a hash from all CRECTO_FIELDS defined


def token : String? #

def token! #

def token=(_token : String | Nil) #

def update_from_hash(hash : Hash(String, DbValue)) #

def update_primary_key(val) #

def updated_at : Time? #

def updated_at=(_updated_at : Time | Nil) #

def updated_at_to_now #

def updated_at_value #