class

Marten::CLI::Generator::Model::FieldDefinition

Inherits Reference / Object

Represents a model field definition.

Field definitions are specified using either of the following formats:

  • name:type
  • name: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.

Constructors

from_argument(argument : String) : FieldDefinition
Source
new(name : String, type : String, qualifier : String | Nil, modifiers : Array(Modifier))
Source

Instance methods

modifiers
Source
name
Source
primary_key?
Source
qualifier
Source
render
Source
type
Source

Nested types