zino_orm

Trait ScalarQuery

Source
pub trait ScalarQuery<K>: Schema<PrimaryKey = K>
where K: Default + Display + PartialEq,
{ // Provided methods async fn find_scalar<T>(query: &Query) -> Result<T, Error> where T: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver> { ... } async fn find_scalars<T>(query: &Query) -> Result<Vec<T>, Error> where T: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver> { ... } async fn find_distinct_scalars<T>(query: &Query) -> Result<Vec<T>, Error> where T: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver> { ... } async fn query_scalar<T>( query: &str, params: Option<&Map>, ) -> Result<T, Error> where T: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver> { ... } async fn query_scalars<T>( query: &str, params: Option<&Map>, ) -> Result<Vec<T>, Error> where T: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver> { ... } 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<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver> { ... } async fn find_primary_key(query: &Query) -> Result<K, Error> where K: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver> { ... } async fn find_primary_keys(query: &Query) -> Result<Vec<K>, Error> where K: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver> { ... } }
Available on crate feature orm-sqlx only.
Expand description

Query on scalar values.

Provided Methods§

Source

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

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<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver>,

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<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver>,

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>) -> Result<T, Error>
where T: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver>,

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>, ) -> Result<Vec<T>, Error>
where T: Send + Unpin + Type<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver>,

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<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver>,

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<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver>,

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<DatabaseDriver> + for<'r> Decode<'r, DatabaseDriver>,

Finds a list of primary keys selected by the query in the table.

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§

Source§

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