class Marten::DB::Field::ManyToMany

Defined in:

marten/db/field.cr
marten/db/field/many_to_many.cr

Constructors

Instance Method Summary

Instance methods inherited from class Marten::DB::Field::Base

blank? : Bool blank?, db_column db_column, db_column! : ::String db_column!, db_column? db_column?, default default, empty_value?(value) : ::Bool empty_value?, from_db(value) from_db, from_db_result_set(result_set : ::DB::ResultSet) from_db_result_set, getter_value?(value) : ::Bool getter_value?, id : String id, index? : Bool index?, null? : Bool null?, prepare_save(record, new_record = false) prepare_save, primary_key? : Bool primary_key?, related_model related_model, relation? relation?, relation_name relation_name, to_column : Management::Column::Base | Nil to_column, to_db(value) : ::DB::Any to_db, truthy_value?(value) truthy_value?, unique? : Bool unique?, validate(record, value) validate

Constructor methods inherited from class Marten::DB::Field::Base

new(id : ::String, primary_key : ::Bool = false, blank : ::Bool = false, null : ::Bool = false, unique : ::Bool = false, index : ::Bool = false, db_column : ::String | Symbol | Nil = nil) new

Constructor Detail

def self.new(id : ::String, to : Model.class, through : Model.class, through_from_field_id : ::String, through_to_field_id : ::String, primary_key = false, blank = false, null = false, unique = false, index = false, db_column = nil, related : Nil | ::String | Symbol = nil) #

[View source]

Instance Method Detail

def db_column #
Description copied from class Marten::DB::Field::Base

Returns the name of the column associated with the considered field.


[View source]
def default #
Description copied from class Marten::DB::Field::Base

Returns the default value of the field if any.


[View source]
def from_db(value) : Nil #
Description copied from class Marten::DB::Field::Base

Converts the raw DB value to the corresponding field value.


[View source]
def from_db_result_set(result_set : ::DB::ResultSet) : Nil #
Description copied from class Marten::DB::Field::Base

Extracts the field value from a DB result set and returns the right object corresponding to this value.


[View source]
def perform_validation(record : Model) #
Description copied from class Marten::DB::Field::Base

:nodoc:


[View source]
def related_model : Marten::DB::Model.class #
Description copied from class Marten::DB::Field::Base

Returns the related model associated with the field.

This method will raise a NotImplementedError exception by default and should only be overriden if the #relation? method returns true (this is the case for fields such as many to one, one to one, etc).


[View source]
def relation? #
Description copied from class Marten::DB::Field::Base

Returns true if the field is a relation.

By default this method will always return false. It should be overriden if the field is intended to handle a relation with another model (eg. like many to one or one to one fields).


[View source]
def relation_name : String #
Description copied from class Marten::DB::Field::Base

Returns the name of the relation on the model associated with the field.

This method will raise a NotImplementedError exception by default and should only be overriden if the #relation? method returns true (this is the case for fields such as many to one, one to one, etc).


[View source]
def through : Marten::DB::Model.class #

[View source]
def through_from_field #

Returns the field on the through model that points to the model defining the many-to-many field.


[View source]
def through_from_field_id : String #

[View source]
def through_to_field #

Returns the field on the through model that points to the model targeted by the many-to-many field.


[View source]
def through_to_field_id : String #

[View source]
def to_column : Management::Column::Base | Nil #
Description copied from class Marten::DB::Field::Base

Returns a migration column object corresponding to the field at hand.


[View source]
def to_db(value) : ::DB::Any #
Description copied from class Marten::DB::Field::Base

Converts the field value to the corresponding DB value.


[View source]