pub struct FieldDef {
pub name: String,
pub column_name: String,
pub rust_type: RustType,
pub sql_type: SqlType,
pub nullable: bool,
pub attributes: Vec<FieldAttribute>,
pub default: Option<String>,
pub doc: Option<String>,
}Expand description
Definition of a model field.
Fields§
§name: StringField name in Rust (snake_case).
column_name: StringColumn name in SQL (may differ from field name).
rust_type: RustTypeRust type.
sql_type: SqlTypeSQL type.
nullable: boolWhether the field is nullable.
attributes: Vec<FieldAttribute>Field attributes.
default: Option<String>Default value expression (SQL).
doc: Option<String>Documentation comment.
Implementations§
Source§impl FieldDef
impl FieldDef
Sourcepub fn is_primary_key(&self) -> bool
pub fn is_primary_key(&self) -> bool
Check if this field is a primary key.
Sourcepub fn is_indexed(&self) -> bool
pub fn is_indexed(&self) -> bool
Check if this field is indexed.
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Check if this field is encrypted.
Sourcepub fn is_updated_at(&self) -> bool
pub fn is_updated_at(&self) -> bool
Check if this field auto-updates on modification.
Sourcepub fn to_sql_column(&self) -> String
pub fn to_sql_column(&self) -> String
Generate SQL column definition.
Sourcepub fn to_typescript(&self) -> String
pub fn to_typescript(&self) -> String
Generate TypeScript field.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FieldDef
impl<'de> Deserialize<'de> for FieldDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for FieldDef
impl RefUnwindSafe for FieldDef
impl Send for FieldDef
impl Sync for FieldDef
impl Unpin for FieldDef
impl UnwindSafe for FieldDef
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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