pub struct TableDef {
pub name: String,
pub schema: Option<String>,
pub struct_name: String,
pub fields: Vec<FieldDef>,
pub indexes: Vec<IndexDef>,
pub composite_indexes: Vec<CompositeIndexDef>,
pub soft_delete: bool,
pub tenant_field: Option<String>,
pub doc: Option<String>,
}Expand description
Complete table definition.
Fields§
§name: StringTable name.
schema: Option<String>Optional schema name (e.g., for multi-tenancy).
struct_name: StringRust struct name.
fields: Vec<FieldDef>Field definitions.
indexes: Vec<IndexDef>Index definitions.
composite_indexes: Vec<CompositeIndexDef>Composite indexes.
soft_delete: boolWhether soft delete is enabled.
tenant_field: Option<String>Tenant field for row-level security.
doc: Option<String>Documentation comment.
Implementations§
Source§impl TableDef
impl TableDef
Sourcepub fn primary_key(&self) -> Option<&FieldDef>
pub fn primary_key(&self) -> Option<&FieldDef>
Get the primary key field.
Sourcepub fn indexed_fields(&self) -> Vec<&FieldDef>
pub fn indexed_fields(&self) -> Vec<&FieldDef>
Get all indexed fields.
Sourcepub fn unique_fields(&self) -> Vec<&FieldDef>
pub fn unique_fields(&self) -> Vec<&FieldDef>
Get all unique fields.
Sourcepub fn to_create_table_sql(&self) -> String
pub fn to_create_table_sql(&self) -> String
Generate CREATE TABLE SQL.
Sourcepub fn to_typescript_interface(&self) -> String
pub fn to_typescript_interface(&self) -> String
Generate TypeScript interface.
Sourcepub fn qualified_name(&self) -> String
pub fn qualified_name(&self) -> String
Get the fully qualified table name.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TableDef
impl<'de> Deserialize<'de> for TableDef
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 TableDef
impl RefUnwindSafe for TableDef
impl Send for TableDef
impl Sync for TableDef
impl Unpin for TableDef
impl UnwindSafe for TableDef
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