pub struct TableDef {
pub table_id: TableId,
pub columns: Vec<ColumnDef>,
pub primary_key: Vec<ColumnName>,
pub indexes: Vec<IndexDef>,
}Expand description
Definition of a table in the schema.
Fields§
§table_id: TableIdUnderlying store table ID.
columns: Vec<ColumnDef>Column definitions in order.
primary_key: Vec<ColumnName>Primary key column names (in order).
indexes: Vec<IndexDef>Secondary indexes on this table.
Implementations§
Source§impl TableDef
impl TableDef
Sourcepub fn new(
table_id: TableId,
columns: Vec<ColumnDef>,
primary_key: Vec<ColumnName>,
) -> Self
pub fn new( table_id: TableId, columns: Vec<ColumnDef>, primary_key: Vec<ColumnName>, ) -> Self
Creates a new table definition.
Sourcepub fn with_index(self, index: IndexDef) -> Self
pub fn with_index(self, index: IndexDef) -> Self
Adds an index to this table definition.
Sourcepub fn find_index_for_column(&self, column: &ColumnName) -> Option<&IndexDef>
pub fn find_index_for_column(&self, column: &ColumnName) -> Option<&IndexDef>
Finds an index that can be used for the given column.
Sourcepub fn find_column(&self, name: &ColumnName) -> Option<(usize, &ColumnDef)>
pub fn find_column(&self, name: &ColumnName) -> Option<(usize, &ColumnDef)>
Finds a column by name.
Sourcepub fn is_primary_key(&self, name: &ColumnName) -> bool
pub fn is_primary_key(&self, name: &ColumnName) -> bool
Returns true if the given column is part of the primary key.
Sourcepub fn primary_key_position(&self, name: &ColumnName) -> Option<usize>
pub fn primary_key_position(&self, name: &ColumnName) -> Option<usize>
Returns the index of a column in the primary key.
Sourcepub fn primary_key_indices(&self) -> Vec<usize>
pub fn primary_key_indices(&self) -> Vec<usize>
Returns the column indices that form the primary key.
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 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