module Marten::DB::Model::Table::ClassMethods

Defined in:

marten/db/model/table.cr

Instance Method Summary

Instance Method Detail

def db_index(name : String | Symbol, field_names : Array(String) | Array(Symbol)) : Nil #

Allows to explicitly configure a new index for a specific set of fields.

This method allows to configure a new index targetting a specific set of #fields. Indexes must be associated with a mandatory name that must be unique accross all the indexes of the considered model.


[View source]
def db_indexes #

Returns the configured database indexes.


[View source]
def db_table(db_table : String | Symbol) #

Allows to explicitely define the name of the table associated with the model.


[View source]
def db_table #

Returns the name of the table associated with the considered model.

Unless explicitely specified, the table name is automatically generated based on the label of the app associated with the considered model and the class name of the model.


[View source]
def db_unique_constraint(name : String | Symbol, field_names : Array(String) | Array(Symbol)) : Nil #

Allows to explicitly configure a new unique constraint for a specific set of fields.

This method allows to configure a new unique constraint targetting a specific set of #fields. Unique constraints must be associated with a mandatory name that must be unique accross all the constraints of the considered model.


[View source]
def db_unique_constraints #

Returns the configured unique database constraints.


[View source]
def fields #

Returns all the fields instances associated with the current model.


[View source]
def get_field(id : String | Symbol) #

Allows to retrieve a specific field instance associated with the current model.

The returned object will be an instance of a subclass of Marten::DB::Field::Base.


[View source]