pub trait ModelAccessor<K>: Schema<PrimaryKey = K>{
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§
Provided Methods§
Sourcefn visibility(&self) -> &str
fn visibility(&self) -> &str
Returns the visibility
field.
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Returns the description
field.
Sourcefn created_at(&self) -> DateTime
fn created_at(&self) -> DateTime
Returns the created_at
field.
Sourcefn updated_at(&self) -> DateTime
fn updated_at(&self) -> DateTime
Returns the updated_at
field.
Sourcefn deleted_at(&self) -> Option<DateTime>
fn deleted_at(&self) -> Option<DateTime>
Returns the deleted_at
field.
Sourcefn has_namespace_prefix(&self, namespace: &str) -> bool
fn has_namespace_prefix(&self, namespace: &str) -> bool
Returns true
if self
has the namespace prefix.
Sourcefn has_namespace_suffix(&self, namespace: &str) -> bool
fn has_namespace_suffix(&self, namespace: &str) -> bool
Returns true
if self
has the namespace suffix.
Sourcefn has_visibility(&self, visibility: &str) -> bool
fn has_visibility(&self, visibility: &str) -> bool
Returns true
if the model has the specific visibility.
Sourcefn is_internal(&self) -> bool
fn is_internal(&self) -> bool
Returns true
if the visibility
is Internal
.
Sourcefn is_protected(&self) -> bool
fn is_protected(&self) -> bool
Returns true
if the visibility
is Protected
.
Sourcefn is_private(&self) -> bool
fn is_private(&self) -> bool
Returns true
if the visibility
is Private
.
Sourcefn has_status(&self, status: &str) -> bool
fn has_status(&self, status: &str) -> bool
Returns true
if the model has the specific status.
Sourcefn is_inactive(&self) -> bool
fn is_inactive(&self) -> bool
Returns true
if the status
is Inactive
.
Sourcefn is_deleted(&self) -> bool
fn is_deleted(&self) -> bool
Returns true
if the status
is Deleted
.
Sourcefn is_archived(&self) -> bool
fn is_archived(&self) -> bool
Returns true
if the status
is Archived
.
Sourcefn has_description(&self) -> bool
fn has_description(&self) -> bool
Returns true
if the description
is nonempty.
Sourcefn get_extra_value(&self, key: &str) -> Option<&JsonValue>
fn get_extra_value(&self, key: &str) -> Option<&JsonValue>
Returns a reference to the value corresponding to the key in extra
.
Sourcefn next_version(&self) -> u64
fn next_version(&self) -> u64
Returns the next version for the model.
Sourcefn current_version_filters(&self) -> Map
fn current_version_filters(&self) -> Map
Constructs the query filters for the model of the current version.
Sourcefn current_version_query(&self) -> Query
fn current_version_query(&self) -> Query
Constructs the Query
for the model of the current version.
Sourcefn next_version_filters(&self) -> Map
fn next_version_filters(&self) -> Map
Constructs the query filters for the model of the next version.
Sourcefn next_version_updates(&self) -> Map
fn next_version_updates(&self) -> Map
Constructs the mutation updates for the model of the next version.
Sourcefn next_version_mutation(&self, updates: &mut Map) -> Mutation
fn next_version_mutation(&self, updates: &mut Map) -> Mutation
Constructs the Mutation
for the model of the next version.
Sourcefn next_edition(&self) -> u32
fn next_edition(&self) -> u32
Returns the next edition for the model.
Sourcefn current_edition_filters(&self) -> Map
fn current_edition_filters(&self) -> Map
Constructs the query filters for the model of the current edition.
Sourcefn current_edition_query(&self) -> Query
fn current_edition_query(&self) -> Query
Constructs the Query
for the model of the current edition.
Sourcefn next_edition_filters(&self) -> Map
fn next_edition_filters(&self) -> Map
Constructs the query filters for the model of the next edition.
Sourcefn next_edition_updates(&self) -> Map
fn next_edition_updates(&self) -> Map
Constructs the mutation updates for the model of the next edition.
Sourcefn next_edition_mutation(&self, updates: &mut Map) -> Mutation
fn next_edition_mutation(&self, updates: &mut Map) -> Mutation
Constructs the Mutation
for the model of the next edition.
Sourcefn soft_delete_mutation(&self) -> Mutation
fn soft_delete_mutation(&self) -> Mutation
Constructs a Mutation
for logically deleting the model.
Sourcefn lock_mutation(&self) -> Mutation
fn lock_mutation(&self) -> Mutation
Constructs a Mutation
for locking the model.
Sourcefn archive_mutation(&self) -> Mutation
fn archive_mutation(&self) -> Mutation
Constructs a Mutation
for archiving the model.
Sourcefn default_snapshot_query() -> Query
fn default_snapshot_query() -> Query
Constructs a default snapshot Query
for the model.
Sourcefn default_list_query() -> Query
fn default_list_query() -> Query
Constructs a default list Query
for the model.
Sourceasync fn check_constraints(&self) -> Result<Validation, Error>
async fn check_constraints(&self) -> Result<Validation, Error>
Checks the constraints for the model.
Sourceasync fn fetch(query: &Query) -> Result<Vec<Map>, Error>
async fn fetch(query: &Query) -> Result<Vec<Map>, Error>
Fetches the data of models seleted by the Query
.
Sourceasync fn fetch_by_id(id: &K) -> Result<Map, Error>
async fn fetch_by_id(id: &K) -> Result<Map, Error>
Fetches the data of a model seleted by the primary key.
Sourceasync fn soft_delete_by_id(id: &K) -> Result<(), Error>
async fn soft_delete_by_id(id: &K) -> Result<(), Error>
Deletes a model of the primary key by setting the status as Deleted
.
Sourceasync fn lock_by_id(id: &K) -> Result<(), Error>
async fn lock_by_id(id: &K) -> Result<(), Error>
Locks a model of the primary key by setting the status as Locked
.
Sourceasync fn archive_by_id(id: &K) -> Result<(), Error>
async fn archive_by_id(id: &K) -> Result<(), Error>
Archives a model of the primary key by setting the status as Archived
.
Sourceasync fn mutate_by_id(
id: &K,
data: &mut Map,
extension: Option<<Self as ModelHooks>::Extension>,
) -> Result<(Validation, Self), Error>
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.
Sourceasync fn random_associations() -> Result<Map, Error>
async fn random_associations() -> Result<Map, Error>
Generates random associations for the model.
Sourceasync fn mock() -> Result<(Validation, Self), Error>
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.