class Good

Included Modules

Defined in:

models/good.cr

Constant Summary

ASSOCIATIONS = [{type: GoodsCategory, assoc_name: goods_categories, foreign_key: :good_id, relationship_type: :has_many, through: nil}, {type: Category, assoc_name: categories, foreign_key: :good_id, relationship_type: :has_many, through: [:goods_categories, :category]}, {type: OrderItem, assoc_name: order_items, foreign_key: :good_id, relationship_type: :has_many, through: nil}, {type: GoodsInStore, assoc_name: goods_in_stores, foreign_key: :good_id, relationship_type: :has_many, through: nil}, {type: Store, assoc_name: stores, foreign_key: :good_id, relationship_type: :has_many, through: [:goods_in_stores, :store]}, {type: Unit, assoc_name: unit, foreign_key: :unit_id, relationship_type: :belongs_to, through: nil}] of Nil
COLUMNS = [{name: id, type: Int32, nilable: false, autogenerated: true, value: nil, serialized: false}, {name: created_at, type: Time, nilable: false, autogenerated: true, value: nil, serialized: false}, {name: updated_at, type: Time, nilable: false, autogenerated: true, value: nil, serialized: false}, {name: unit_id, type: Unit::PrimaryKeyType, nilable: true, autogenerated: false, value: nil, serialized: false}, {name: name, type: String, nilable: false, autogenerated: false, value: nil, serialized: false}, {name: description, type: String, nilable: false, autogenerated: false, value: nil, serialized: false}, {name: price, type: Float64, nilable: false, autogenerated: false, value: nil, serialized: false}, {name: weight, type: Float64, nilable: false, autogenerated: false, value: nil, serialized: false}] of Nil
PRIMARY_KEY_NAME = :id
PRIMARY_KEY_TYPE = Int32

Constructors

Class Method Summary

Instance Method Summary

Class methods inherited from class BaseModel

database : Avram::Database.class database

Constructor Detail

def self.new(id : Int32, created_at : Time, updated_at : Time, unit_id : Int32 | Nil, name : String, description : String, price : PG::Numeric, weight : PG::Numeric) #

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

Class Method Detail

def self.column_names : Array(Symbol) #

def self.columns : Array(NamedTuple(name: Symbol, nilable: Bool, type: String)) #

def self.ensure_correct_column_mappings! #

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

def self.primary_key_name : Symbol | Nil #

def self.schema_enforcer_validations #

def self.table_name : String #

Instance Method Detail

def _preloaded_categories=(_preloaded_categories : Nil | Array(Category)) #

def _preloaded_goods_categories=(_preloaded_goods_categories : Nil | Array(GoodsCategory)) #

def _preloaded_goods_in_stores=(_preloaded_goods_in_stores : Nil | Array(GoodsInStore)) #

def _preloaded_order_items=(_preloaded_order_items : Nil | Array(OrderItem)) #

def _preloaded_stores=(_preloaded_stores : Nil | Array(Store)) #

def base_query_class : ::Good::BaseQuery.class #

This makes it easy for plugins and extensions to use the base SaveOperation


def categories : Array(Category) #

def categories! : Array(Category) #

def categories_count : Int64 #

def categories_query #

def created_at : Time #

def created_at=(_created_at : Time::Lucky::ColumnType) #

def delete_operation_class : ::Good::DeleteOperation.class #

def description : String #

def description=(_description : String::Lucky::ColumnType) #

def goods_categories : Array(GoodsCategory) #

def goods_categories! : Array(GoodsCategory) #

def goods_categories_count : Int64 #

def goods_categories_query #

def goods_in_stores : Array(GoodsInStore) #

def goods_in_stores! : Array(GoodsInStore) #

def goods_in_stores_count : Int64 #

def goods_in_stores_query #

def id : Int32 #

def id=(_id : Int32::Lucky::ColumnType) #

def name : String #

def name=(_name : String::Lucky::ColumnType) #

def order_items : Array(OrderItem) #

def order_items! : Array(OrderItem) #

def order_items_count : Int64 #

def order_items_query #

def price : Float64 #

def price=(_price : PG::Numeric) #

def save_operation_class : ::Good::SaveOperation.class #

def stores : Array(Store) #

def stores! : Array(Store) #

def stores_count : Int64 #

def stores_query #

def unit : Unit | Nil #

def unit! : Unit | Nil #

def unit_count : Int64 #

def unit_id : Unit::PrimaryKeyType | Nil #

def unit_id=(_unit_id : Unit::PrimaryKeyType::Lucky::ColumnType | Nil) #

def unit_query #

def updated_at : Time #

def updated_at=(_updated_at : Time::Lucky::ColumnType) #

def weight : Float64 #

def weight=(_weight : PG::Numeric) #