pub struct Table { /* private fields */ }Expand description
Schema-first 表构建器。
Implementations§
Source§impl Table
impl Table
Sourcepub fn fields<I>(self, fields: I) -> Selfwhere
I: IntoIterator<Item = Field>,
pub fn fields<I>(self, fields: I) -> Selfwhere
I: IntoIterator<Item = Field>,
批量添加字段;支持数组、Vec 和任意字段迭代器。
Sourcepub fn unique_named<I, C>(self, name: impl Into<String>, fields: I) -> Self
pub fn unique_named<I, C>(self, name: impl Into<String>, fields: I) -> Self
添加指定名称的复合唯一索引。
Sourcepub fn index_named<I, C>(self, name: impl Into<String>, fields: I) -> Self
pub fn index_named<I, C>(self, name: impl Into<String>, fields: I) -> Self
添加指定名称的复合普通索引。
Sourcepub fn check_named(
self,
name: impl Into<String>,
expression: impl Into<String>,
) -> Self
pub fn check_named( self, name: impl Into<String>, expression: impl Into<String>, ) -> Self
添加指定名称的 MySQL CHECK 约束。
表达式属于受信任的应用定义,不得来自请求或运行时配置。
Sourcepub fn foreign_key_named<I, C, R, RC>(
self,
name: impl Into<String>,
columns: I,
referenced_table: impl Into<String>,
referenced_columns: R,
) -> Selfwhere
I: IntoIterator<Item = C>,
C: Into<ColumnName>,
R: IntoIterator<Item = RC>,
RC: Into<ColumnName>,
pub fn foreign_key_named<I, C, R, RC>(
self,
name: impl Into<String>,
columns: I,
referenced_table: impl Into<String>,
referenced_columns: R,
) -> Selfwhere
I: IntoIterator<Item = C>,
C: Into<ColumnName>,
R: IntoIterator<Item = RC>,
RC: Into<ColumnName>,
添加指定名称的复合外键;更新和删除规则固定为 RESTRICT。
Sourcepub fn default_order(self, order: Order) -> Self
pub fn default_order(self, order: Order) -> Self
设置首个默认排序规则。
Sourcepub fn then_order(self, order: Order) -> Self
pub fn then_order(self, order: Order) -> Self
追加默认排序规则。
Sourcepub fn build(self) -> Result<TableDefinition, BaseError>
pub fn build(self) -> Result<TableDefinition, BaseError>
校验并生成不可变表定义。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Table
impl !UnwindSafe for Table
impl Freeze for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
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