zino_orm

Trait ModelAccessor

Source
pub trait ModelAccessor<K>: Schema<PrimaryKey = K>
where K: Default + Display + PartialEq,
{
Show 55 methods // Required method fn id(&self) -> &K; // Provided methods fn name(&self) -> &str { ... } fn namespace(&self) -> &str { ... } fn visibility(&self) -> &str { ... } fn status(&self) -> &str { ... } fn description(&self) -> &str { ... } fn extra(&self) -> Option<&Map> { ... } fn created_at(&self) -> DateTime { ... } fn updated_at(&self) -> DateTime { ... } fn deleted_at(&self) -> Option<DateTime> { ... } fn version(&self) -> u64 { ... } fn edition(&self) -> u32 { ... } fn snapshot(&self) -> Map { ... } fn has_name(&self) -> bool { ... } fn has_namespace_prefix(&self, namespace: &str) -> bool { ... } fn has_namespace_suffix(&self, namespace: &str) -> bool { ... } fn has_visibility(&self, visibility: &str) -> bool { ... } fn is_public(&self) -> bool { ... } fn is_internal(&self) -> bool { ... } fn is_protected(&self) -> bool { ... } fn is_private(&self) -> bool { ... } fn has_status(&self, status: &str) -> bool { ... } fn is_active(&self) -> bool { ... } fn is_inactive(&self) -> bool { ... } fn is_locked(&self) -> bool { ... } fn is_deleted(&self) -> bool { ... } fn is_archived(&self) -> bool { ... } fn has_description(&self) -> bool { ... } fn get_extra_value(&self, key: &str) -> Option<&JsonValue> { ... } fn next_version(&self) -> u64 { ... } fn current_version_filters(&self) -> Map { ... } fn current_version_query(&self) -> Query { ... } fn next_version_filters(&self) -> Map { ... } fn next_version_updates(&self) -> Map { ... } fn next_version_mutation(&self, updates: &mut Map) -> Mutation { ... } fn next_edition(&self) -> u32 { ... } fn current_edition_filters(&self) -> Map { ... } fn current_edition_query(&self) -> Query { ... } fn next_edition_filters(&self) -> Map { ... } fn next_edition_updates(&self) -> Map { ... } fn next_edition_mutation(&self, updates: &mut Map) -> Mutation { ... } fn soft_delete_mutation(&self) -> Mutation { ... } fn lock_mutation(&self) -> Mutation { ... } fn archive_mutation(&self) -> Mutation { ... } fn default_snapshot_query() -> Query { ... } fn default_list_query() -> Query { ... } async fn check_constraints(&self) -> Result<Validation, Error> { ... } async fn fetch(query: &Query) -> Result<Vec<Map>, Error> { ... } async fn fetch_by_id(id: &K) -> Result<Map, Error> { ... } async fn soft_delete_by_id(id: &K) -> Result<(), Error> { ... } async fn lock_by_id(id: &K) -> Result<(), Error> { ... } async fn archive_by_id(id: &K) -> Result<(), Error> { ... } async fn mutate_by_id( id: &K, data: &mut Map, extension: Option<<Self as ModelHooks>::Extension>, ) -> Result<(Validation, Self), Error> { ... } async fn random_associations() -> Result<Map, Error> { ... } async fn mock() -> Result<(Validation, Self), Error> { ... }
}
Expand description

Access model fields.

This trait can be derived by zino_derive::ModelAccessor.

Required Methods§

Source

fn id(&self) -> &K

Returns the id field, i.e. the primary key.

Provided Methods§

Source

fn name(&self) -> &str

Returns the name field.

Source

fn namespace(&self) -> &str

Returns the namespace field.

Source

fn visibility(&self) -> &str

Returns the visibility field.

Source

fn status(&self) -> &str

Returns the status field.

Source

fn description(&self) -> &str

Returns the description field.

Source

fn extra(&self) -> Option<&Map>

Returns the extra field.

Source

fn created_at(&self) -> DateTime

Returns the created_at field.

Source

fn updated_at(&self) -> DateTime

Returns the updated_at field.

Source

fn deleted_at(&self) -> Option<DateTime>

Returns the deleted_at field.

Source

fn version(&self) -> u64

Returns the version field.

Source

fn edition(&self) -> u32

Returns the edition field.

Source

fn snapshot(&self) -> Map

Returns a snapshot of the model.

Source

fn has_name(&self) -> bool

Returns true if the name is nonempty.

Source

fn has_namespace_prefix(&self, namespace: &str) -> bool

Returns true if self has the namespace prefix.

Source

fn has_namespace_suffix(&self, namespace: &str) -> bool

Returns true if self has the namespace suffix.

Source

fn has_visibility(&self, visibility: &str) -> bool

Returns true if the model has the specific visibility.

Source

fn is_public(&self) -> bool

Returns true if the visibility is Public.

Source

fn is_internal(&self) -> bool

Returns true if the visibility is Internal.

Source

fn is_protected(&self) -> bool

Returns true if the visibility is Protected.

Source

fn is_private(&self) -> bool

Returns true if the visibility is Private.

Source

fn has_status(&self, status: &str) -> bool

Returns true if the model has the specific status.

Source

fn is_active(&self) -> bool

Returns true if the status is Active.

Source

fn is_inactive(&self) -> bool

Returns true if the status is Inactive.

Source

fn is_locked(&self) -> bool

Returns true if the status is Locked.

Source

fn is_deleted(&self) -> bool

Returns true if the status is Deleted.

Source

fn is_archived(&self) -> bool

Returns true if the status is Archived.

Source

fn has_description(&self) -> bool

Returns true if the description is nonempty.

Source

fn get_extra_value(&self, key: &str) -> Option<&JsonValue>

Returns a reference to the value corresponding to the key in extra.

Source

fn next_version(&self) -> u64

Returns the next version for the model.

Source

fn current_version_filters(&self) -> Map

Constructs the query filters for the model of the current version.

Source

fn current_version_query(&self) -> Query

Constructs the Query for the model of the current version.

Source

fn next_version_filters(&self) -> Map

Constructs the query filters for the model of the next version.

Source

fn next_version_updates(&self) -> Map

Constructs the mutation updates for the model of the next version.

Source

fn next_version_mutation(&self, updates: &mut Map) -> Mutation

Constructs the Mutation for the model of the next version.

Source

fn next_edition(&self) -> u32

Returns the next edition for the model.

Source

fn current_edition_filters(&self) -> Map

Constructs the query filters for the model of the current edition.

Source

fn current_edition_query(&self) -> Query

Constructs the Query for the model of the current edition.

Source

fn next_edition_filters(&self) -> Map

Constructs the query filters for the model of the next edition.

Source

fn next_edition_updates(&self) -> Map

Constructs the mutation updates for the model of the next edition.

Source

fn next_edition_mutation(&self, updates: &mut Map) -> Mutation

Constructs the Mutation for the model of the next edition.

Source

fn soft_delete_mutation(&self) -> Mutation

Constructs a Mutation for logically deleting the model.

Source

fn lock_mutation(&self) -> Mutation

Constructs a Mutation for locking the model.

Source

fn archive_mutation(&self) -> Mutation

Constructs a Mutation for archiving the model.

Source

fn default_snapshot_query() -> Query

Constructs a default snapshot Query for the model.

Source

fn default_list_query() -> Query

Constructs a default list Query for the model.

Source

async fn check_constraints(&self) -> Result<Validation, Error>

Checks the constraints for the model.

Source

async fn fetch(query: &Query) -> Result<Vec<Map>, Error>

Fetches the data of models seleted by the Query.

Source

async fn fetch_by_id(id: &K) -> Result<Map, Error>

Fetches the data of a model seleted by the primary key.

Source

async fn soft_delete_by_id(id: &K) -> Result<(), Error>

Deletes a model of the primary key by setting the status as Deleted.

Source

async fn lock_by_id(id: &K) -> Result<(), Error>

Locks a model of the primary key by setting the status as Locked.

Source

async fn archive_by_id(id: &K) -> Result<(), Error>

Archives a model of the primary key by setting the status as Archived.

Source

async fn mutate_by_id( id: &K, data: &mut Map, extension: Option<<Self as ModelHooks>::Extension>, ) -> Result<(Validation, Self), Error>

Mutates a model of the primary key with the JSON data and the optional extension.

Source

async fn random_associations() -> Result<Map, Error>

Generates random associations for the model.

Source

async fn mock() -> Result<(Validation, Self), Error>

Attempts to generate a mocked model.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§