zino_model::collection

Struct Collection

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

The collection model.

Trait Implementations§

Source§

impl Clone for Collection

Source§

fn clone(&self) -> Collection

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Collection

Source§

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

Formats the value using the given formatter. Read more
Source§

impl DecodeRow<SqliteRow> for Collection

Source§

type Error = Error

The error type.
Source§

fn decode_row(row: &DatabaseRow) -> Result<Self, Self::Error>

Decodes a row and attempts to create an instance of Self.
Source§

impl Default for Collection

Source§

fn default() -> Collection

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Collection

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Entity for Collection

Source§

const PRIMARY_KEY: Self::Column = {transmute(0x00): <collection::Collection as zino_orm::Entity>::Column}

The primary key column.
Source§

type Column = CollectionColumn

The column type.
Source§

fn format_column(col: &Self::Column) -> String

Formats the column name.
Source§

impl Model for Collection

Source§

const MODEL_NAME: &'static str = "collection"

Model name.
Source§

fn new() -> Self

Creates a new instance.
Source§

fn read_map(&mut self, data: &Map) -> Validation

Updates the model using the json object and returns the validation result.
Source§

const ITEM_NAME: (&'static str, &'static str) = _

Data item name.
Source§

fn model_name() -> &'static str

Returns the model name.
Source§

fn try_from_map(data: Map<String, Value>) -> Result<Self, Error>

Attempts to construct a model from a json object.
Source§

fn try_from_avro_record(data: Vec<(String, Value)>) -> Result<Self, Error>

Attempts to construct a model from an Avro record.
Source§

fn into_map(self) -> Map<String, Value>

Consumes the model and returns as a json object. Read more
Source§

fn into_avro_record(self) -> Vec<(String, Value)>

Consumes the model and returns as an Avro record. Read more
Source§

fn data_item(value: impl Into<Value>) -> Map<String, Value>

Constructs an instance of Map for the data item.
Source§

fn data_items<T>(values: Vec<T>) -> Map<String, Value>
where T: Into<Value>,

Constructs an instance of Map for the data items.
Source§

impl ModelAccessor<Uuid> for Collection

Source§

fn id(&self) -> &Uuid

Returns the id field, i.e. the primary key.
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 version(&self) -> u64

Returns the version field.
Source§

fn edition(&self) -> u32

Returns the edition field.
Source§

fn snapshot(&self) -> ZinoMap

Returns a snapshot of the model.
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<ZinoValidation, ZinoError>

Checks the constraints for the model.
Source§

async fn fetch(query: &Query) -> Result<Vec<ZinoMap>, ZinoError>

Fetches the data of models seleted by the Query.
Source§

async fn fetch_by_id(id: &Uuid) -> Result<ZinoMap, ZinoError>

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

async fn random_associations() -> Result<ZinoMap, ZinoError>

Generates random associations for the model.
Source§

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

Returns the deleted_at field.
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<&Value>

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<String, Value>

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<String, Value>

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

fn next_version_updates(&self) -> Map<String, Value>

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

fn next_version_mutation(&self, updates: &mut Map<String, Value>) -> 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<String, Value>

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<String, Value>

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

fn next_edition_updates(&self) -> Map<String, Value>

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

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

Constructs the Mutation for the model of the next edition.
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<String, Value>, extension: Option<Self::Extension>, ) -> Result<(Validation, Self), Error>

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

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

Attempts to generate a mocked model.
Source§

impl ModelHooks for Collection

Source§

type Data = ()

Model data.
Source§

type Extension = UserSession<Uuid>

Extension data.
Source§

async fn after_extract(&mut self, session: Self::Extension) -> Result<(), Error>

A hook running after extracting the model data.
Source§

async fn before_validation( data: &mut Map, extension: Option<&Self::Extension>, ) -> Result<(), Error>

A hook running before validating the model data.
Source§

async fn before_extract() -> Result<(), Error>

A hook running before extracting the model data.
Source§

async fn after_validation( &mut self, _model: &mut Map<String, Value>, ) -> Result<(), Error>

A hook running after validating the model data.
Source§

async fn before_create_table() -> Result<(), Error>

A hook running before creating the table.
Source§

async fn after_create_table() -> Result<(), Error>

A hook running after creating the table.
Source§

async fn before_scan(query: &str) -> Result<QueryContext, Error>

A hook running before scanning the table.
Source§

async fn after_scan(ctx: &QueryContext) -> Result<(), Error>

A hook running after scanning the table.
Source§

async fn before_insert_check( &mut self, _extension: Option<&Self::Extension>, ) -> Result<(), Error>

A hook running before checking the constraints when inserting a model into the table.
Source§

async fn before_insert(&mut self) -> Result<Self::Data, Error>

A hook running before inserting a model into the table.
Source§

async fn after_insert(ctx: &QueryContext, data: Self::Data) -> Result<(), Error>

A hook running after inserting a model into the table.
Source§

async fn before_soft_delete(&mut self) -> Result<Self::Data, Error>

A hook running before logically deleting a model from the table.
Source§

async fn after_soft_delete( ctx: &QueryContext, data: Self::Data, ) -> Result<(), Error>

A hook running after logically deleting a model from the table.
Source§

async fn before_lock(&mut self) -> Result<Self::Data, Error>

A hook running before locking a model in the table.
Source§

async fn after_lock(ctx: &QueryContext, data: Self::Data) -> Result<(), Error>

A hook running after locking a model in the table.
Source§

async fn before_archive(&mut self) -> Result<Self::Data, Error>

A hook running before archiving a model in the table.
Source§

async fn after_archive( ctx: &QueryContext, data: Self::Data, ) -> Result<(), Error>

A hook running after archiving a model in the table.
Source§

async fn before_update(&mut self) -> Result<Self::Data, Error>

A hook running before updating a model in the table.
Source§

async fn after_update(ctx: &QueryContext, data: Self::Data) -> Result<(), Error>

A hook running after updating a model in the table.
Source§

async fn before_upsert(&mut self) -> Result<Self::Data, Error>

A hook running before updating or inserting a model into the table.
Source§

async fn after_upsert(ctx: &QueryContext, data: Self::Data) -> Result<(), Error>

A hook running after updating or inserting a model into the table.
Source§

async fn before_save(&mut self) -> Result<Self::Data, Error>

A hook running before saving a model into the table.
Source§

async fn after_save(ctx: &QueryContext, _data: Self::Data) -> Result<(), Error>

A hook running after saving a model into the table.
Source§

async fn before_delete(&mut self) -> Result<Self::Data, Error>

A hook running before deleting a model from the table.
Source§

async fn after_delete( self, ctx: &QueryContext, _data: Self::Data, ) -> Result<(), Error>

A hook running after deleting a model from the table.
Source§

async fn before_count(_query: &Query) -> Result<(), Error>

A hook running before counting the models in the table.
Source§

async fn after_count(ctx: &QueryContext) -> Result<(), Error>

A hook running after counting the models in the table.
Source§

async fn before_aggregate(_query: &Query) -> Result<(), Error>

A hook running before aggregating the models in the table.
Source§

async fn after_aggregate(ctx: &QueryContext) -> Result<(), Error>

A hook running after aggregating the models in the table.
Source§

async fn before_query(_query: &Query) -> Result<(), Error>

A hook running before selecting the models with a Query from the table.
Source§

async fn after_query(ctx: &QueryContext) -> Result<(), Error>

A hook running after selecting the models with a Query from the table.
Source§

async fn before_mutation( _query: &Query, _mutation: &mut Mutation, ) -> Result<(), Error>

A hook running before updating the models with a Mutation in the table.
Source§

async fn after_mutation(ctx: &QueryContext) -> Result<(), Error>

A hook running after updating the models with a Mutation in the table.
Source§

async fn before_list( _query: &mut Query, _extension: Option<&Self::Extension>, ) -> Result<(), Error>

A hook running before listing the models with a Query from the table.
Source§

async fn before_batch_delete( _query: &mut Query, _extension: Option<&Self::Extension>, ) -> Result<(), Error>

A hook running before batch deleting the models with a Query from the table.
Source§

async fn after_decode(_model: &mut Map<String, Value>) -> Result<(), Error>

A hook running after decoding the model as a Map.
Source§

async fn before_respond( _model: &mut Map<String, Value>, _extension: Option<&Self::Extension>, ) -> Result<(), Error>

A hook running before returning the model data as a HTTP response.
Source§

async fn before_mock() -> Result<Map<String, Value>, Error>

A hook running before mocking the model data.
Source§

async fn after_mock(&mut self) -> Result<(), Error>

A hook running after mocking the model data.
Source§

impl PartialEq for Collection

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Schema for Collection

Source§

const PRIMARY_KEY_NAME: &'static str = "id"

Primary key name.
Source§

const READER_NAME: &'static str = "main"

Reader name.
Source§

const WRITER_NAME: &'static str = "main"

Writer name.
Source§

const TABLE_NAME: Option<&'static str> = None

Optional custom table name.
Source§

type PrimaryKey = Uuid

Primary key.
Source§

fn primary_key(&self) -> &Self::PrimaryKey

Returns the primary key.
Source§

fn primary_key_value(&self) -> JsonValue

Returns the primary key as a JSON value.
Source§

fn primary_key_column() -> &'static Column<'static>

Returns the primary key column.
Source§

fn schema() -> &'static Schema

Returns a reference to the Avro schema.
Source§

fn columns() -> &'static [Column<'static>]

Returns a reference to the columns.
Source§

fn fields() -> &'static [&'static str]

Returns a reference to the column fields.
Source§

fn read_only_fields() -> &'static [&'static str]

Returns a reference to the read-only column fields.
Source§

fn write_only_fields() -> &'static [&'static str]

Returns a reference to the write-only column fields.
Source§

async fn acquire_reader() -> Result<&'static ConnectionPool, ZinoError>

Retrieves a connection pool for the model reader.
Source§

async fn acquire_writer() -> Result<&'static ConnectionPool, ZinoError>

Retrieves a connection pool for the model writer.
Source§

fn table_name() -> &'static str

Returns the table name.
Source§

fn model_namespace() -> &'static str

Returns the model namespace.
Source§

fn driver_name() -> &'static str

Returns the driver name. Read more
Source§

fn table_prefix() -> &'static str

Returns the prefix for the table name.
Source§

fn namespace_prefix() -> &'static str

Returns the prefix for the model namespace.
Source§

fn get_column(key: &str) -> Option<&Column<'static>>

Gets a column for the field.
Source§

fn get_writable_column(key: &str) -> Option<&Column<'static>>

Gets a column for the field if it is writable.
Source§

fn has_column(key: &str) -> bool

Returns true if the model has a column for the specific field.
Source§

fn default_query() -> Query

Constructs a default Query for the model.
Source§

fn default_mutation() -> Mutation

Constructs a default Mutation for the model.
Source§

fn init_reader() -> Result<&'static ConnectionPool, Error>

Initializes the model reader.
Source§

fn init_writer() -> Result<&'static ConnectionPool, Error>

Initializes the model writer.
Source§

async fn create_table() -> Result<(), Error>

Creates a database table for the model.
Source§

async fn synchronize_schema() -> Result<(), Error>

Synchronizes the table schema for the model.
Source§

async fn create_indexes() -> Result<u64, Error>

Creates indexes for the model.
Source§

async fn prepare_insert(self) -> Result<QueryContext, Error>

Prepares the SQL to insert the model into the table.
Source§

async fn insert(self) -> Result<QueryContext, Error>

Inserts the model into the table.
Source§

async fn prepare_insert_many(models: Vec<Self>) -> Result<QueryContext, Error>

Prepares the SQL to insert many models into the table.
Source§

async fn insert_many(models: Vec<Self>) -> Result<QueryContext, Error>

Inserts many models into the table.
Source§

async fn prepare_insert_from_subquery<C, E>( columns: &[C], subquery: QueryBuilder<E>, ) -> Result<QueryContext, Error>
where C: AsRef<str>, E: Entity + Schema,

Prepares the SQL to insert models selected by a subquery.
Source§

async fn insert_from_subquery<C, E>( columns: &[C], subquery: QueryBuilder<E>, ) -> Result<QueryContext, Error>
where C: AsRef<str>, E: Entity + Schema,

Inserts the models selected by a subquery.
Source§

async fn prepare_update(self) -> Result<QueryContext, Error>

Prepares the SQL to update the model in the table.
Source§

async fn update(self) -> Result<QueryContext, Error>

Updates the model in the table.
Source§

async fn prepare_update_partial<C>( self, columns: &[C], ) -> Result<QueryContext, Error>
where C: AsRef<str>,

Prepares the SQL to update the model for partial columns in the table.
Source§

async fn update_partial<C>(self, columns: &[C]) -> Result<QueryContext, Error>
where C: AsRef<str>,

Updates the model for partial columns in the table.
Source§

async fn prepare_update_one( query: &Query, mutation: &mut Mutation, ) -> Result<QueryContext, Error>

Prepares the SQL to update at most one model selected by the query in the table.
Source§

async fn update_one( query: &Query, mutation: &mut Mutation, ) -> Result<QueryContext, Error>

Updates at most one model selected by the query in the table.
Source§

async fn prepare_update_many( query: &Query, mutation: &mut Mutation, ) -> Result<QueryContext, Error>

Prepares the SQL to update many models selected by the query in the table.
Source§

async fn update_many( query: &Query, mutation: &mut Mutation, ) -> Result<QueryContext, Error>

Updates many models selected by the query in the table.
Source§

async fn prepare_upsert(self) -> Result<QueryContext, Error>

Prepares the SQL to update or insert the model into the table.
Source§

async fn upsert(self) -> Result<QueryContext, Error>

Updates or inserts the model into the table.
Source§

async fn prepare_delete() -> Result<QueryContext, Error>

Prepares the SQL to delete the model in the table.
Source§

async fn delete(self) -> Result<QueryContext, Error>

Deletes the model in the table.
Source§

async fn prepare_delete_one(query: &Query) -> Result<QueryContext, Error>

Prepares the SQL to delete at most one model selected by the query in the table.
Source§

async fn delete_one(query: &Query) -> Result<QueryContext, Error>

Deletes at most one model selected by the query in the table.
Source§

async fn prepare_delete_many(query: &Query) -> Result<QueryContext, Error>

Prepares the SQL to delete many models selected by the query in the table.
Source§

async fn delete_many(query: &Query) -> Result<QueryContext, Error>

Deletes many models selected by the query in the table.
Source§

async fn prepare_delete_by_subquery<C, E>( columns: &[C], subquery: QueryBuilder<E>, ) -> Result<QueryContext, Error>
where C: AsRef<str>, E: Entity + Schema,

Prepares the SQL to delete models selected by a subquery.
Source§

async fn delete_by_subquery<C, E>( columns: &[C], subquery: QueryBuilder<E>, ) -> Result<QueryContext, Error>
where C: AsRef<str>, E: Entity + Schema,

Deletes the models selected by a subquery.
Source§

async fn find<T>(query: &Query) -> Result<Vec<T>, Error>
where T: DecodeRow<SqliteRow, Error = Error>,

Finds a list of models selected by the query in the table, and decodes it as Vec<T>.
Source§

async fn find_as<T>(query: &Query) -> Result<Vec<T>, Error>

Finds a list of models selected by the query in the table, and parses it as Vec<T>.
Source§

async fn find_one<T>(query: &Query) -> Result<Option<T>, Error>
where T: DecodeRow<SqliteRow, Error = Error>,

Finds one model selected by the query in the table, and decodes it as an instance of type T.
Source§

async fn find_one_as<T>(query: &Query) -> Result<Option<T>, Error>

Finds one model selected by the query in the table, and parses it as an instance of type T.
Source§

async fn populate<C>( query: &mut Query, data: &mut Vec<Map<String, Value>>, columns: &[C], ) -> Result<u64, Error>
where C: AsRef<str>,

Populates the related data in the corresponding columns for Vec<Map> using a merged select on the primary key, which solves the N+1 problem.
Source§

async fn populate_one<C>( query: &mut Query, data: &mut Map<String, Value>, columns: &[C], ) -> Result<(), Error>
where C: AsRef<str>,

Populates the related data in the corresponding columns for Map using a merged select on the primary key, which solves the N+1 problem.
Source§

async fn lookup<M, T>( query: &Query, join_on: &JoinOn<Self, M>, ) -> Result<Vec<T>, Error>
where M: Schema, T: DecodeRow<SqliteRow, Error = Error>,

Performs a join to another table to filter rows in the “joined” table, and decodes it as Vec<T>.
Source§

async fn lookup_as<M, T>( query: &Query, join_on: &JoinOn<Self, M>, ) -> Result<Vec<T>, Error>
where M: Schema, T: DeserializeOwned,

Performs a join to another table to filter rows in the “joined” table, and parses it as Vec<T>.
Source§

async fn exists(query: &Query) -> Result<bool, Error>

Checks whether there is a model selected by the query in the table.
Source§

async fn count(query: &Query) -> Result<u64, Error>

Counts the number of rows selected by the query in the table.
Source§

async fn count_many<C, T>( query: &Query, columns: &[(C, bool)], ) -> Result<T, Error>
where C: AsRef<str>, T: DecodeRow<SqliteRow, Error = Error>,

Counts the number of rows selected by the query in the table. The boolean value determines whether it only counts distinct values or not.
Source§

async fn count_many_as<C, T>( query: &Query, columns: &[(C, bool)], ) -> Result<T, Error>
where C: AsRef<str>, T: DeserializeOwned,

Counts the number of rows selected by the query in the table, and parses it as an instance of type T.
Source§

async fn aggregate<T>(query: &Query) -> Result<Vec<T>, Error>
where T: DecodeRow<SqliteRow, Error = Error>,

Aggregates the rows selected by the query in the table.
Source§

async fn aggregate_as<T>(query: &Query) -> Result<Vec<T>, Error>

Aggregates the rows selected by the query in the table, and parses it as an instance of type T.
Source§

async fn execute( query: &str, params: Option<&Map<String, Value>>, ) -> Result<QueryContext, Error>

Executes the query in the table, and returns the total number of rows affected.
Source§

async fn query<T>( query: &str, params: Option<&Map<String, Value>>, ) -> Result<Vec<T>, Error>
where T: DecodeRow<SqliteRow, Error = Error>,

Executes the query in the table, and decodes it as Vec<T>.
Source§

async fn query_as<T>( query: &str, params: Option<&Map<String, Value>>, ) -> Result<Vec<T>, Error>

Executes the query in the table, and parses it as Vec<T>.
Source§

async fn query_one<T>( query: &str, params: Option<&Map<String, Value>>, ) -> Result<Option<T>, Error>
where T: DecodeRow<SqliteRow, Error = Error>,

Executes the query in the table, and decodes it as an instance of type T.
Source§

async fn query_one_as<T>( query: &str, params: Option<&Map<String, Value>>, ) -> Result<Option<T>, Error>

Executes the query in the table, and parses it as an instance of type T.
Source§

async fn prepare_delete_by_id() -> Result<QueryContext, Error>

Prepares the SQL to delete a model selected by the primary key in the table.
Source§

async fn delete_by_id( primary_key: &Self::PrimaryKey, ) -> Result<QueryContext, Error>

Deletes a model selected by the primary key in the table.
Source§

async fn prepare_update_by_id( mutation: &mut Mutation, ) -> Result<QueryContext, Error>

Prepares the SQL to update a model selected by the primary key in the table.
Source§

async fn update_by_id<T>( primary_key: &Self::PrimaryKey, mutation: &mut Mutation, ) -> Result<Option<T>, Error>
where T: DecodeRow<SqliteRow, Error = Error>,

Updates a model selected by the primary key in the table, and decodes it as an instance of type T.
Source§

async fn find_by_id<T>( primary_key: &Self::PrimaryKey, ) -> Result<Option<T>, Error>
where T: DecodeRow<SqliteRow, Error = Error>,

Finds a model selected by the primary key in the table, and decodes it as an instance of type T.
Source§

async fn try_get_model(primary_key: &Self::PrimaryKey) -> Result<Self, Error>

Finds a model selected by the primary key in the table, and parses it as Self.
Source§

async fn sample(size: usize) -> Result<Vec<Value>, Error>

Randomly selects the specified number of models from the table and returns a list of the primary key values.
Source§

async fn filter<T>(primary_key_values: Vec<T>) -> Result<Vec<Value>, Error>
where T: IntoSqlValue,

Filters the values of the primary key.
Source§

async fn is_unique_on<C, T>(&self, columns: Vec<(C, T)>) -> Result<bool, Error>
where C: AsRef<str>, T: IntoSqlValue,

Returns true if the model is unique on the column values.
Source§

impl Serialize for Collection

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Collection

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, dst: *mut u8)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<M, K> ModelHelper<K> for M
where M: Schema<PrimaryKey = K>, K: Default + Display + PartialEq,

Source§

fn secret_key() -> &'static [u8]

Returns the secret key for the model. It should have at least 64 bytes. Read more
Source§

fn encrypt_password(password: &str) -> Result<String, Error>

Encrypts the password for the model.
Source§

fn verify_password( password: &str, encrypted_password: &str, ) -> Result<bool, Error>

Verifies the password for the model.
Source§

fn translate_model(model: &mut Map<String, Value>)

Translates the model data.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<M, K> ScalarQuery<K> for M
where M: Schema<PrimaryKey = K>, K: Default + Display + PartialEq,

Source§

async fn find_scalar<T>(query: &Query) -> Result<T, Error>
where T: Send + Unpin + Type<Sqlite> + for<'r> Decode<'r, Sqlite>,

Finds a value selected by the query in the table, and decodes it as a single concrete type T.
Source§

async fn find_scalars<T>(query: &Query) -> Result<Vec<T>, Error>
where T: Send + Unpin + Type<Sqlite> + for<'r> Decode<'r, Sqlite>,

Finds a list of scalar values selected by the query in the table, and decodes it as a Vec<T>.
Source§

async fn find_distinct_scalars<T>(query: &Query) -> Result<Vec<T>, Error>
where T: Send + Unpin + Type<Sqlite> + for<'r> Decode<'r, Sqlite>,

Finds a list of distinct scalar values selected by the query in the table, and decodes it as a Vec<T>.
Source§

async fn query_scalar<T>( query: &str, params: Option<&Map<String, Value>>, ) -> Result<T, Error>
where T: Send + Unpin + Type<Sqlite> + for<'r> Decode<'r, Sqlite>,

Executes the query in the table, and decodes it as a single concrete type T.
Source§

async fn query_scalars<T>( query: &str, params: Option<&Map<String, Value>>, ) -> Result<Vec<T>, Error>
where T: Send + Unpin + Type<Sqlite> + for<'r> Decode<'r, Sqlite>,

Executes the query in the table, and decodes the scalar values as Vec<T>.
Source§

async fn find_scalar_by_id<C, T>( primary_key: &Self::PrimaryKey, column: C, ) -> Result<T, Error>
where C: AsRef<str>, T: Send + Unpin + Type<Sqlite> + for<'r> Decode<'r, Sqlite>,

Finds a model selected by the primary key in the table, and decodes the column value as a single concrete type T.
Source§

async fn find_primary_key(query: &Query) -> Result<K, Error>
where K: Send + Unpin + Type<Sqlite> + for<'r> Decode<'r, Sqlite>,

Finds a primary key selected by the query in the table.
Source§

async fn find_primary_keys(query: &Query) -> Result<Vec<K>, Error>
where K: Send + Unpin + Type<Sqlite> + for<'r> Decode<'r, Sqlite>,

Finds a list of primary keys selected by the query in the table.
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<'c, M, K> Transaction<K, Transaction<'c, Sqlite>> for M
where M: Schema<PrimaryKey = K>, K: Default + Display + PartialEq,

Source§

async fn transaction<F, T>(tx: F) -> Result<T, Error>
where F: for<'t> FnOnce(&'t mut Transaction<'c, Sqlite>) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 't>>,

Executes the specific operations inside of a transaction. If the operations return an error, the transaction will be rolled back; if not, the transaction will be committed.
Source§

async fn transactional_execute( queries: &[&str], params: Option<&Map<String, Value>>, ) -> Result<u64, Error>

Executes the queries sequentially inside of a transaction. If it returns an error, the transaction will be rolled back; if not, the transaction will be committed.
Source§

async fn transactional_insert<S>( self, associations: Vec<S>, ) -> Result<u64, Error>
where S: Schema,

Inserts the model and its associations inside of a transaction.
Source§

async fn transactional_update<S>( queries: (&Query, &Query), mutations: (&mut Mutation, &mut Mutation), ) -> Result<u64, Error>
where S: Schema,

Updates the models inside of a transaction.
Source§

async fn transactional_delete<S>( queries: (&Query, &Query), ) -> Result<u64, Error>
where S: Schema,

Deletes the models inside of a transaction.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T