Skip to main content

Schema

Struct Schema 

Source
pub struct Schema {
    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 read: Option<Vec<String>>,
    pub write: Option<Vec<String>>,
    pub indexes: Vec<Value>,
    pub datasource: Option<String>,
    pub namespace: 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 的输出顺序依赖它

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

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

§datasource: Option<String>

绑定的数据源名(可选;缺省 = default,回落单源 Mongo)。见 crate::datasource

§namespace: Option<String>

连接内的库/schema 名(可选;缺省 = null,用连接自身默认:Mongo db 实例的库名、 PG 的 search_path、MySQL 的连接库、SQLite 的 main)。 与 datasource/collection 构成定位三元组,见 super::Registry::get_by_location。

Implementations§

Source§

impl Schema

Source

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

Source

pub fn source(&self) -> &str

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

Source

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

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

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.