class

Silvio::Database::Client

Inherits DB::Mappable / JSON::Serializable / Crecto::Schema::BelongsTo / Crecto::Schema::HasOne / Crecto::Schema::HasMany / Crecto::Schema / Crecto::Model / Reference / Object

Constants

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, UInt64, UInt32, UInt16, UInt8, Float32, Float64, Bool, Time, Json, PkeyValue, UUID, Int32 | Int64, UInt32 | UInt64, Float32 | Float64, Array(String), Array(Int32), Array(Int64), Array(Int16), Array(UInt32), Array(UInt64), Array(UInt16), Array(UInt8), Array(Float32), Array(Float64), Array(Bool), Array(Time), Array(Json), Array(UUID)]

macro constants CRECTO_VALID_FIELD_TYPES = [String, Int64, Int32, Int16, UInt64, UInt32, UInt16, UInt8, Float32, Float64, Bool, Time, Int32 | Int64, UInt32 | UInt64, Float32 | Float64, Json, PkeyValue, Array(String), Array(Int64), Array(Int32), Array(Int16), Array(UInt8), Array(UInt16), Array(UInt32), Array(UInt64) Array(Float32), Array(Float64), Array(Bool), Array(Time), Array(Int32 | Int64), Array(UInt32 | UInt64), Array(Float32 | Float64), Array(Json), Array(PkeyValue)]

Constructors

new(pull : JSON::PullParser)
new(__temp_115 : DB::ResultSet)
new(*, __pull_for_json_serializable pull : JSON::PullParser)

Class methods

add_destroy_association(a)
Source
add_nullify_association(a)
Source
association_type_for_association(association : Symbol)

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

cast(attributes : NamedTuple, whitelist : Tuple = attributes.keys)
Source
cast(attributes : Hash(Symbol, T), whitelist : Array(Symbol) = attributes.keys) forall T
Source
cast(attributes : Hash(String, T), whitelist : Array(String) = attributes.keys) forall T
Source
cast

Class methods for mass assignment

Source
cast!(attributes : NamedTuple)
Source
cast!

Class methods for compile-time type safe mass assignment

Source
changeset_fields

Class method to get the changeset_fields

Source
created_at_field
Source
destroy_associations
Source
fields
Source
foreign_key_for_association(association : Symbol) : Symbol | Nil

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

foreign_key_for_association(klass : Crecto::Model.class)
foreign_key_value_for_association(association : Symbol, item)

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

from_rs(__temp_115 : DB::ResultSet)
klass_for_association(association : Symbol)

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

nullify_associations
Source
primary_key_field

Return the primary key field as a String

Source
primary_key_field_symbol

Return the primary key field as a Symbol

Source
set_value_for_association(association : Symbol, item, items)

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

table_name

Class method to get the table name

Source
through_key_for_association(association : Symbol) : Symbol | Nil

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

updated_at_field
Source
use_primary_key?
Source
validate(message : String, block : Silvio::Database::Client -> _)

Validates generic block against an instance of the class

Instance methods

address
address!
address=(_address : String | Nil)
cast(attributes : NamedTuple, whitelist : Tuple = attributes.keys)
cast(attributes : Hash(Symbol, T), whitelist : Array(Symbol) = attributes.keys) forall T
cast(attributes : Hash(String, T), whitelist : Array(String) = attributes.keys) forall T
cast

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

cast!(attributes : NamedTuple)
Source
cast!

Instance method for compile-time type safe mass assignment

Source
created_at
created_at=(_created_at : Time | Nil)
created_at_to_now
created_at_value
get_changeset
Source
id
id=(_id : PkeyValue | Nil)
initial_values

Instance properties

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

Instance properties

name
name!

Builds fields' cast typed method

name=(_name : String | Nil)
network
Source
network=(val : Network | Nil)
Source
network?
Source
network_id
network_id!
network_id=(_network_id : PkeyValue | Nil)
pkey_value

Returns the value of the primary key field

to_query_hash(include_virtual = false)

Builds a hash from all CRECTO_FIELDS defined

token
token!
token=(_token : String | Nil)
update_from_hash(hash : Hash(String, DbValue))
update_primary_key(val)
updated_at
updated_at=(_updated_at : Time | Nil)
updated_at_to_now
updated_at_value