pub struct Field { /* private fields */ }Expand description
A single parsed column definition.
Implementations§
Source§impl Field
impl Field
Sourcepub fn parse(spec: &str) -> Result<Self>
pub fn parse(spec: &str) -> Result<Self>
Parse one name:type[:modifier...] spec. Type defaults to string.
Sourcepub fn parse_all(specs: &[&str]) -> Result<Vec<Field>>
pub fn parse_all(specs: &[&str]) -> Result<Vec<Field>>
Parse every spec in specs, short-circuiting on the first error.
Sourcepub fn column_name(&self) -> String
pub fn column_name(&self) -> String
The database column name. References get an _id suffix.
Sourcepub fn is_required(&self) -> bool
pub fn is_required(&self) -> bool
Whether the column (and therefore the model field) is NOT NULL. References are always non-null (the builder enforces it).
Sourcepub fn wants_index(&self) -> bool
pub fn wants_index(&self) -> bool
Whether this field requested its own index.
Sourcepub fn params_struct_field(&self) -> String
pub fn params_struct_field(&self) -> String
Render a field for the scaffold’s form-params struct, e.g.
pub title: String, — mirrors the column’s nullability.
Sourcepub fn active_model_set(&self) -> String
pub fn active_model_set(&self) -> String
Render an ActiveModel struct-literal entry from a parsed form, e.g.
title: Set(form.title), (used by create).
Sourcepub fn active_model_assign(&self) -> String
pub fn active_model_assign(&self) -> String
Render an ActiveModel field assignment from a parsed form, e.g.
record.title = Set(form.title); (used by update).
Sourcepub fn html_input_type(&self) -> &'static str
pub fn html_input_type(&self) -> &'static str
The HTML <input type="…"> (or textarea/checkbox) for this column,
used by the scaffold form view.
Sourcepub fn migration_line(&self) -> String
pub fn migration_line(&self) -> String
Render the migration builder line, e.g. t.string("title").not_null();.
references passes the bare name (it appends _id itself).
Sourcepub fn alter_add_line(&self) -> String
pub fn alter_add_line(&self) -> String
Render an alter_table add-column line, e.g.
t.add_column("email", |c| { c.string().not_null(); });. References
become a NOT NULL <name>_id big integer.
Sourcepub fn alter_drop_line(&self) -> String
pub fn alter_drop_line(&self) -> String
Render an alter_table drop-column line, e.g. t.drop_column("email");.
Sourcepub fn model_field(&self) -> String
pub fn model_field(&self) -> String
Render the SeaORM model struct field, e.g. pub title: String, or
pub age: Option<i32>, for a nullable column.
Sourcepub fn sample_form_value(&self) -> Option<&'static str>
pub fn sample_form_value(&self) -> Option<&'static str>
A sample form value for this column, used to build request bodies in the
generated scaffold controller test. None for types that cannot be
represented as a urlencoded scalar (binary), which are omitted.
Sourcepub fn sample_form_pair(&self) -> Option<String>
pub fn sample_form_pair(&self) -> Option<String>
col=value pair for a urlencoded request body, or None to omit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin for Field
impl UnwindSafe for Field
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more