Skip to main content

SqlxQueryExt

Trait SqlxQueryExt 

Source
pub trait SqlxQueryExt<T, C>
where C: CacheCodec,
{ // Required methods fn fetch_one<'q, 'async_trait, DB, A, E>( self, executor: E, query: QueryAs<'q, DB, T, A>, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>> where T: Serialize + DeserializeOwned + Send + Unpin + for<'r> FromRow<'r, DB::Row> + 'static, DB: Database + Send + Sync + 'static + 'async_trait, A: IntoArguments<'q, DB> + Send + 'static + 'async_trait, E: Send + Sync + 'static + 'async_trait, for<'c> &'c E: Executor<'c, Database = DB>, Self: 'async_trait, 'q: 'static + 'async_trait; fn fetch_optional<'q, 'async_trait, DB, A, E>( self, executor: E, query: QueryAs<'q, DB, T, A>, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>> where T: Serialize + DeserializeOwned + Send + Unpin + for<'r> FromRow<'r, DB::Row> + 'static, DB: Database + Send + Sync + 'static + 'async_trait, A: IntoArguments<'q, DB> + Send + 'static + 'async_trait, E: Send + Sync + 'static + 'async_trait, for<'c> &'c E: Executor<'c, Database = DB>, Self: 'async_trait, 'q: 'static + 'async_trait; fn fetch_all<'q, 'async_trait, DB, A, E>( self, executor: E, query: QueryAs<'q, DB, T, A>, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>> where T: Serialize + DeserializeOwned + Send + Unpin + for<'r> FromRow<'r, DB::Row> + 'static, DB: Database + Send + Sync + 'static + 'async_trait, A: IntoArguments<'q, DB> + Send + 'static + 'async_trait, E: Send + Sync + 'static + 'async_trait, for<'c> &'c E: Executor<'c, Database = DB>, Self: 'async_trait, 'q: 'static + 'async_trait; }
Expand description

Convenience SQLx execution methods for DbQuery.

These helpers keep SQLx responsible for query construction and row mapping, while HydraCache owns keying, tags, TTL, serialization, and local single-flight. Use DbQuery::fetch_with when you need a transaction, custom repository call, or a database client that is not pool-like.

Required Methods§

Source

fn fetch_one<'q, 'async_trait, DB, A, E>( self, executor: E, query: QueryAs<'q, DB, T, A>, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: Serialize + DeserializeOwned + Send + Unpin + for<'r> FromRow<'r, DB::Row> + 'static, DB: Database + Send + Sync + 'static + 'async_trait, A: IntoArguments<'q, DB> + Send + 'static + 'async_trait, E: Send + Sync + 'static + 'async_trait, for<'c> &'c E: Executor<'c, Database = DB>, Self: 'async_trait, 'q: 'static + 'async_trait,

Execute a SQLx query on miss and cache exactly one row.

Source

fn fetch_optional<'q, 'async_trait, DB, A, E>( self, executor: E, query: QueryAs<'q, DB, T, A>, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>
where T: Serialize + DeserializeOwned + Send + Unpin + for<'r> FromRow<'r, DB::Row> + 'static, DB: Database + Send + Sync + 'static + 'async_trait, A: IntoArguments<'q, DB> + Send + 'static + 'async_trait, E: Send + Sync + 'static + 'async_trait, for<'c> &'c E: Executor<'c, Database = DB>, Self: 'async_trait, 'q: 'static + 'async_trait,

Execute a SQLx query on miss and cache either one row or None.

Source

fn fetch_all<'q, 'async_trait, DB, A, E>( self, executor: E, query: QueryAs<'q, DB, T, A>, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: Serialize + DeserializeOwned + Send + Unpin + for<'r> FromRow<'r, DB::Row> + 'static, DB: Database + Send + Sync + 'static + 'async_trait, A: IntoArguments<'q, DB> + Send + 'static + 'async_trait, E: Send + Sync + 'static + 'async_trait, for<'c> &'c E: Executor<'c, Database = DB>, Self: 'async_trait, 'q: 'static + 'async_trait,

Execute a SQLx query on miss and cache all returned rows.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, C> SqlxQueryExt<T, C> for DbQuery<T, C>
where C: CacheCodec,