pub struct TableDef {
pub name: String,
pub columns: Vec<ColumnDef>,
pub primary_key: Vec<String>,
pub indexes: Vec<IndexDef>,
pub constraints: Vec<Constraint>,
pub version: u32,
pub created_at: u64,
pub updated_at: u64,
}Expand description
Table definition containing all metadata.
Fields§
§name: StringTable name (unique within database).
columns: Vec<ColumnDef>Column definitions in order.
primary_key: Vec<String>Primary key column names (can be composite).
indexes: Vec<IndexDef>Index definitions.
constraints: Vec<Constraint>Table-level constraints.
version: u32Schema version (for migrations).
created_at: u64Creation timestamp.
updated_at: u64Last modification timestamp.
Implementations§
Source§impl TableDef
impl TableDef
Sourcepub fn add_column(self, column: ColumnDef) -> Self
pub fn add_column(self, column: ColumnDef) -> Self
Add a column to the table.
Sourcepub fn primary_key(self, columns: Vec<String>) -> Self
pub fn primary_key(self, columns: Vec<String>) -> Self
Set primary key columns.
Sourcepub fn add_constraint(self, constraint: Constraint) -> Self
pub fn add_constraint(self, constraint: Constraint) -> Self
Add a constraint.
Sourcepub fn get_column(&self, name: &str) -> Option<&ColumnDef>
pub fn get_column(&self, name: &str) -> Option<&ColumnDef>
Get a column by name.
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Get a column’s ordinal by name.
Sourcepub fn is_primary_key_column(&self, name: &str) -> bool
pub fn is_primary_key_column(&self, name: &str) -> bool
Check whether a column is part of the primary key.
Sourcepub fn validate(&self) -> Result<(), TableDefError>
pub fn validate(&self) -> Result<(), TableDefError>
Validate references within the table definition.
Trait Implementations§
impl Eq for TableDef
impl StructuralPartialEq for TableDef
Auto Trait Implementations§
impl Freeze for TableDef
impl RefUnwindSafe for TableDef
impl Send for TableDef
impl Sync for TableDef
impl Unpin for TableDef
impl UnsafeUnpin 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