pub struct TableDefinition { /* private fields */ }Expand description
不可变的数据表定义。
Implementations§
Source§impl TableDefinition
impl TableDefinition
Sourcepub fn datasource(&self) -> &DatasourceId
pub fn datasource(&self) -> &DatasourceId
返回表所属逻辑数据源。
Sourcepub fn primary_key(&self) -> &str
pub fn primary_key(&self) -> &str
返回主键字段名。
Sourcepub fn primary_keys(&self) -> &[String]
pub fn primary_keys(&self) -> &[String]
返回完整主键列(复合主键时大于一个元素)。
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
返回字段数量。
Sourcepub fn field(&self, name: &str) -> Option<FieldMetadata<'_>>
pub fn field(&self, name: &str) -> Option<FieldMetadata<'_>>
按数据库字段名读取元数据。
Sourcepub fn fields(&self) -> Vec<FieldMetadata<'_>>
pub fn fields(&self) -> Vec<FieldMetadata<'_>>
按字段名排序返回全部字段元数据。
Sourcepub fn soft_delete_field(&self) -> Option<&str>
pub fn soft_delete_field(&self) -> Option<&str>
返回软删除字段名。
Sourcepub fn tenant_key_field(&self) -> Option<&str>
pub fn tenant_key_field(&self) -> Option<&str>
返回唯一租户隔离字段;表未声明租户字段时返回 None。
Sourcepub fn input_schema(&self) -> Value
pub fn input_schema(&self) -> Value
生成供 API catalog 使用的全局写入侧 JSON Schema。
该 schema 是所有角色可写字段的并集;面向当前请求返回结构时应使用
Self::input_schema_for_roles。
Sourcepub fn output_schema(&self) -> Value
pub fn output_schema(&self) -> Value
生成供 API catalog 使用的全局读取侧 JSON Schema。
该 schema 是所有角色可读字段的并集;面向当前请求返回结构时应使用
Self::output_schema_for_roles。
Sourcepub fn input_schema_for_roles(&self, roles: &HashSet<String>) -> Value
pub fn input_schema_for_roles(&self, roles: &HashSet<String>) -> Value
按当前用户角色生成写入侧 JSON Schema。
Sourcepub fn output_schema_for_roles(&self, roles: &HashSet<String>) -> Value
pub fn output_schema_for_roles(&self, roles: &HashSet<String>) -> Value
按当前用户角色生成读取侧 JSON Schema。
Sourcepub fn validate_schema(
&self,
columns: &[SchemaColumn],
) -> SchemaValidationReport
pub fn validate_schema( &self, columns: &[SchemaColumn], ) -> SchemaValidationReport
校验实际数据库列是否兼容当前表定义。
Sourcepub fn bind(&self, pool: Arc<MySqlPool>) -> TableHandle
pub fn bind(&self, pool: Arc<MySqlPool>) -> TableHandle
将表定义绑定到 MySQL 连接池(兼容入口)。
内部会包装为 AnyPool::MySql;需要 PostgreSQL
或其他运行时后端时请使用 TableDefinition::bind_pool。
Sourcepub fn bind_pool(&self, pool: AnyPool) -> TableHandle
pub fn bind_pool(&self, pool: AnyPool) -> TableHandle
将表定义绑定到任意受支持的数据库连接池(沿用表声明的数据源)。
Sourcepub fn bind_datasource(&self, datasource: &Datasource) -> TableHandle
pub fn bind_datasource(&self, datasource: &Datasource) -> TableHandle
将表定义绑定到注册表中的具名数据源(推荐入口)。
Sourcepub fn bind_source_pool(&self, pool: PoolHandle) -> TableHandle
pub fn bind_source_pool(&self, pool: PoolHandle) -> TableHandle
将表定义绑定到带逻辑数据源身份的连接池句柄。
Trait Implementations§
Source§impl Clone for TableDefinition
impl Clone for TableDefinition
Auto Trait Implementations§
impl !RefUnwindSafe for TableDefinition
impl !UnwindSafe for TableDefinition
impl Forget for TableDefinition
impl Freeze for TableDefinition
impl Move for TableDefinition
impl Send for TableDefinition
impl Sync for TableDefinition
impl Unpin for TableDefinition
impl UnsafeUnpin for TableDefinition
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