Skip to main content

Schema

Struct Schema 

Source
pub struct Schema {
Show 14 fields pub name: String, pub collection: String, pub id_prefix: String, pub timestamps: bool, pub fields: HashMap<String, FieldDef>, pub relations: HashMap<String, RelationDef>, pub computes: Vec<(String, ComputeDef)>, pub triggers: Triggers, pub read: Option<Vec<String>>, pub write: Option<Vec<String>>, pub indexes: Vec<Value>, pub source: Option<String>, pub database: Option<String>, pub schema: Option<String>,
}

Fields§

§name: String§collection: String§id_prefix: String§timestamps: bool§fields: HashMap<String, FieldDef>§relations: HashMap<String, RelationDef>§computes: Vec<(String, ComputeDef)>

保持注册顺序:build_agg_stages 的输出顺序依赖它

§triggers: Triggers

写触发器声明(事件 → 触发列表;解析见 super::triggers,规划见 crate::command::triggers)

§read: Option<Vec<String>>§write: Option<Vec<String>>§indexes: Vec<Value>

原始索引定义([{keys: {...}, options: {...}}]),upsert 条件构建依赖 unique 索引

§source: Option<String>

数据源名(由 register_batch 的 Location 注入;None = 缺省 default)。 见 crate::datasource

§database: Option<String>

连接内「库」(由 register_batch 注入;None = 连接默认:Mongo db 实例的库名、 PG 的库、MySQL 的连接库、SQLite 的 main)。

§schema: Option<String>

连接内「schema」(仅 PG;由 register_batch 注入;None = 连接默认 search_path)。

Implementations§

Source§

impl Schema

Source

pub fn compute(&self, name: &str) -> Option<&ComputeDef>

Source

pub fn source(&self) -> &str

解析后的数据源名(缺省 default)

Source

pub fn database(&self) -> Option<&str>

解析后的 database(空串归一为 None)

Source

pub fn schema(&self) -> Option<&str>

解析后的 schema(空串归一为 None;仅 PG)

Source

pub fn location(&self) -> Location

主落点(由 source/database/schema 组装)。

等价于 Registry::primary_location(name) 的投影;链路缺失时的回落。

Source

pub fn id_is_autoincrement(&self) -> bool

_id 是否声明 strategy: "autoincrement"(阶段2:数据库自增主键)

Trait Implementations§

Source§

impl Clone for Schema

Source§

fn clone(&self) -> Self

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 Schema

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.