pub struct TableSpec {
pub name: TableName,
pub title: String,
pub fields: Vec<FieldSpec>,
pub indexes: Vec<TableIndexSpec>,
pub checks: Vec<TableCheckSpec>,
pub foreign_keys: Vec<TableForeignKeySpec>,
}Expand description
表及其唯一字段定义。
Fields§
§name: TableName表名。
title: String用户可见名称。
fields: Vec<FieldSpec>字段集合。
indexes: Vec<TableIndexSpec>表级复合索引。
checks: Vec<TableCheckSpec>表级 CHECK 约束。
foreign_keys: Vec<TableForeignKeySpec>表级外键约束。
Implementations§
Source§impl TableSpec
impl TableSpec
Sourcepub fn unique(self, fields: impl IntoIterator<Item = FieldRef>) -> Self
pub fn unique(self, fields: impl IntoIterator<Item = FieldRef>) -> Self
添加复合唯一索引。
Sourcepub fn unique_named(
self,
name: impl Into<String>,
fields: impl IntoIterator<Item = FieldRef>,
) -> Self
pub fn unique_named( self, name: impl Into<String>, fields: impl IntoIterator<Item = FieldRef>, ) -> Self
添加指定名称的复合唯一索引。
Sourcepub fn index(self, fields: impl IntoIterator<Item = FieldRef>) -> Self
pub fn index(self, fields: impl IntoIterator<Item = FieldRef>) -> Self
添加复合普通索引。
Sourcepub fn index_named(
self,
name: impl Into<String>,
fields: impl IntoIterator<Item = FieldRef>,
) -> Self
pub fn index_named( self, name: impl Into<String>, fields: impl IntoIterator<Item = FieldRef>, ) -> 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
添加指定名称的 CHECK 约束。
Sourcepub fn foreign_key_named(
self,
name: impl Into<String>,
fields: impl IntoIterator<Item = FieldRef>,
referenced_fields: impl IntoIterator<Item = FieldRef>,
) -> Self
pub fn foreign_key_named( self, name: impl Into<String>, fields: impl IntoIterator<Item = FieldRef>, referenced_fields: impl IntoIterator<Item = FieldRef>, ) -> Self
添加指定名称的复合外键;更新和删除规则固定为 RESTRICT。
Sourcepub fn table_definition(&self) -> Result<TableDefinition, BaseError>
pub fn table_definition(&self) -> Result<TableDefinition, BaseError>
生成 schema 同步和 TableQuery 使用的不可变执行产物。
Trait Implementations§
impl Eq for TableSpec
impl StructuralPartialEq for TableSpec
Auto Trait Implementations§
impl Freeze for TableSpec
impl RefUnwindSafe for TableSpec
impl Send for TableSpec
impl Sync for TableSpec
impl Unpin for TableSpec
impl UnsafeUnpin for TableSpec
impl UnwindSafe for TableSpec
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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