pub struct Tables { /* private fields */ }Expand description
统一封装列表参数、View 字段、分页与关系批量加载。
Implementations§
Source§impl Tables
impl Tables
Sourcepub fn new(query: TableQuery) -> Self
pub fn new(query: TableQuery) -> Self
从已经绑定权限和租户范围的 TableQuery 创建。
Sourcepub fn view(self, view: &CompiledTableView) -> Result<Self, BaseError>
pub fn view(self, view: &CompiledTableView) -> Result<Self, BaseError>
应用启动期预编译的 View 字段。
Sourcepub fn relations(self, loader: RelationLoader) -> Self
pub fn relations(self, loader: RelationLoader) -> Self
配置启动期预编译的关系批量加载器。
Sourcepub fn where_from(
self,
conditions: &[WhereCondition],
) -> Result<Self, BaseError>
pub fn where_from( self, conditions: &[WhereCondition], ) -> Result<Self, BaseError>
应用通用筛选条件;空集合是恒真条件,不改变现有查询范围。
Sourcepub fn params(self, params: QueryParams) -> Result<Self, BaseError>
pub fn params(self, params: QueryParams) -> Result<Self, BaseError>
一次性应用标准 QueryParams。
Sourcepub fn params_table() -> QueryParams
pub fn params_table() -> QueryParams
返回标准列表参数默认值。
Sourcepub async fn table_list(self) -> Result<PaginatedResult<Record>, BaseError>
pub async fn table_list(self) -> Result<PaginatedResult<Record>, BaseError>
执行标准分页列表。
Sourcepub async fn table_select(self) -> Result<Vec<Record>, BaseError>
pub async fn table_select(self) -> Result<Vec<Record>, BaseError>
执行选择器数据查询。
底层 all() 一次性读取全部匹配行,不受 TableQuery 最大分页限制保护;
调用方必须先通过 where/search 条件把结果规模约束在内存可承载范围内。
Sourcepub async fn table_tree(self) -> Result<Vec<TableTreeNode>, BaseError>
pub async fn table_tree(self) -> Result<Vec<TableTreeNode>, BaseError>
查询全量选择结果并按默认 id / parent_id 组装树。
节点数受 DEFAULT_TREE_MAX_NODES 限制,超出即报错;需要自定义上限的
树 View 应使用 Tables::table_tree_view 并在 TreeViewSpec 中配置。
Sourcepub async fn table_tree_view(
self,
view: &CompiledTableView,
) -> Result<Vec<TableTreeNode>, BaseError>
pub async fn table_tree_view( self, view: &CompiledTableView, ) -> Result<Vec<TableTreeNode>, BaseError>
按启动期已校验的 View 树拓扑查询并组装节点。
节点数上限取 TreeViewSpec::max_nodes(缺省 DEFAULT_TREE_MAX_NODES),
超出即报错,避免全表无界读入内存。
Sourcepub fn build_tree(
rows: Vec<Record>,
id_field: &str,
parent_field: &str,
) -> Result<Vec<TableTreeNode>, BaseError>
pub fn build_tree( rows: Vec<Record>, id_field: &str, parent_field: &str, ) -> Result<Vec<TableTreeNode>, BaseError>
将已查询记录组装为树;关系键只用于内存索引,不进入 SQL。
Sourcepub async fn table_list_with_relations<E>(
self,
executor: &E,
) -> Result<TableListResult, BaseError>where
E: RelationBatchExecutor,
pub async fn table_list_with_relations<E>(
self,
executor: &E,
) -> Result<TableListResult, BaseError>where
E: RelationBatchExecutor,
执行分页列表并按关系种类批量加载展示数据。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Tables
impl !UnwindSafe for Tables
impl Forget for Tables
impl Freeze for Tables
impl Move for Tables
impl Send for Tables
impl Sync for Tables
impl Unpin for Tables
impl UnsafeUnpin for Tables
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