class
Marten::CLI::Generator::Model::FieldDefinition
- Marten::CLI::Generator::Model::FieldDefinition
- Reference
- Object
Overview
Represents a model field definition.
Field definitions are specified using either of the following formats:
name:typename:type{qualifier}name:type:modifier:modifier
Where #name is the name of the field and #type is the type of the field.
#qualifier can be required depending on the considered field type; when this is the case, it corresponds to a
mandatory field option. For example, label:string{128} will produce a string field whose max_size option
is set to 128. Another example: author:many_to_one{User} will produce a many-to-one field whose to
option is set to target the User model.
modifier is an optional field modifier. Field modifiers are used to specify additional (but non-mandatory)
field options. For example: name:string:uniq will produce a string field whose unique option is set to
true. Another example: name:string:uniq:index will produce a string field whose unique and index
options are set to true.
Defined in:
marten/cli/generator/model/field_definition.crmarten/cli/generator/model/field_definition/qualifier_renderer.cr
Constructors
- .from_argument(argument : String) : FieldDefinition
- .new(name : String, type : String, qualifier : String | Nil, modifiers : Array(Modifier))
Instance Method Summary
- #modifiers : Array(Marten::CLI::Generator::Model::FieldDefinition::Modifier)
- #name : String
- #primary_key?
- #qualifier : String?
- #render : String
- #type : String