Skip to main content

Tables

Struct Tables 

Source
pub struct Tables { /* private fields */ }
Expand description

统一封装列表参数、View 字段、分页与关系批量加载。

Implementations§

Source§

impl Tables

Source

pub fn new(query: TableQuery) -> Self

从已经绑定权限和租户范围的 TableQuery 创建。

Source

pub fn view(self, view: &CompiledTableView) -> Result<Self, BaseError>

应用启动期预编译的 View 字段。

Source

pub fn relations(self, loader: RelationLoader) -> Self

配置启动期预编译的关系批量加载器。

Source

pub fn where_from( self, conditions: &[WhereCondition], ) -> Result<Self, BaseError>

应用通用筛选条件;空集合是恒真条件,不改变现有查询范围。

Source

pub fn search(self, keyword: Option<&str>) -> Result<Self, BaseError>

在定义允许搜索的文本字段上应用关键词。

Source

pub fn order(self, field: &str, order: SortOrder) -> Result<Self, BaseError>

应用受权限保护的排序。

Source

pub fn page(self, page: usize, limit: usize) -> Result<Self, BaseError>

应用分页。

Source

pub fn params(self, params: QueryParams) -> Result<Self, BaseError>

一次性应用标准 QueryParams。

Source

pub fn params_table() -> QueryParams

返回标准列表参数默认值。

Source

pub async fn table_list(self) -> Result<PaginatedResult<Record>, BaseError>

执行标准分页列表。

Source

pub async fn table_select(self) -> Result<Vec<Record>, BaseError>

执行选择器数据查询。

底层 all() 一次性读取全部匹配行,不受 TableQuery 最大分页限制保护; 调用方必须先通过 where/search 条件把结果规模约束在内存可承载范围内。

Source

pub async fn table_tree(self) -> Result<Vec<TableTreeNode>, BaseError>

查询全量选择结果并按默认 id / parent_id 组装树。

节点数受 DEFAULT_TREE_MAX_NODES 限制,超出即报错;需要自定义上限的 树 View 应使用 Tables::table_tree_view 并在 TreeViewSpec 中配置。

Source

pub async fn table_tree_view( self, view: &CompiledTableView, ) -> Result<Vec<TableTreeNode>, BaseError>

按启动期已校验的 View 树拓扑查询并组装节点。

节点数上限取 TreeViewSpec::max_nodes(缺省 DEFAULT_TREE_MAX_NODES), 超出即报错,避免全表无界读入内存。

Source

pub fn build_tree( rows: Vec<Record>, id_field: &str, parent_field: &str, ) -> Result<Vec<TableTreeNode>, BaseError>

将已查询记录组装为树;关系键只用于内存索引,不进入 SQL。

Source

pub async fn table_list_with_relations<E>( self, executor: &E, ) -> Result<TableListResult, BaseError>

执行分页列表并按关系种类批量加载展示数据。

Trait Implementations§

Source§

impl Clone for Tables

Source§

fn clone(&self) -> Tables

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tables

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more