Trait DeleteRepositoryTransaction

Source
pub trait DeleteRepositoryTransaction<M: Model>: DeleteRepository<M> + TransactionRepository<M> {
    // Provided methods
    fn delete_by_id_in_transaction<'a>(
        &'a self,
        id: impl Into<M::Id> + Send + 'a,
    ) -> impl Future<Output = Result<(), Error>> + Send + 'a
       where M::Id: 'a { ... }
    fn delete_by_filter_in_transaction<'a>(
        &'a self,
        filter: impl SqlFilter<'a> + Send + 'a,
    ) -> impl Future<Output = Result<(), Error>> + Send + 'a { ... }
    fn delete_by_values_in_transaction<'a, I>(
        &'a self,
        column: &'static str,
        values: I,
    ) -> impl Future<Output = Result<(), Error>> + Send + 'a
       where M::Id: Type<Database> + Encode<'a, Database> + 'a,
             I: IntoIterator<Item = M::Id> + Send + 'a,
             I::IntoIter: Send + 'a { ... }
}

Provided Methods§

Source

fn delete_by_id_in_transaction<'a>( &'a self, id: impl Into<M::Id> + Send + 'a, ) -> impl Future<Output = Result<(), Error>> + Send + 'a
where M::Id: 'a,

Source

fn delete_by_filter_in_transaction<'a>( &'a self, filter: impl SqlFilter<'a> + Send + 'a, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Source

fn delete_by_values_in_transaction<'a, I>( &'a self, column: &'static str, values: I, ) -> impl Future<Output = Result<(), Error>> + Send + 'a
where M::Id: Type<Database> + Encode<'a, Database> + 'a, I: IntoIterator<Item = M::Id> + Send + 'a, I::IntoIter: Send + 'a,

Examples found in repository?
examples/basic_repo.rs (line 210)
178async fn main() {
179    install_default_drivers();
180
181    initialize_db_pool(
182        PoolOptions::new()
183            .max_connections(21)
184            .min_connections(5)
185            .idle_timeout(Duration::from_secs(60 * 10))
186            .max_lifetime(Duration::from_secs(60 * 60 * 24))
187            .acquire_timeout(Duration::from_secs(20))
188            .connect(&DATABASE_URL)
189            .await
190            .expect("Failed to connect to database"),
191    );
192
193    let user = User {
194        id: 1,
195        name: String::new(),
196    };
197
198    USER_REPO.save_ref(&user).await.unwrap();
199
200    USER_REPO.save_in_transaction(user.clone()).await.unwrap();
201
202    USER_REPO
203        .save_with_context(user.clone(), UserContext::System)
204        .await
205        .unwrap();
206
207    USER_REPO.with_transaction(action).await.unwrap();
208
209    USER_REPO
210        .delete_by_values_in_transaction("id", [1, 2, 3, 11, 22])
211        .await
212        .unwrap();
213
214    USER_REPO
215        .get_one_by_filter(UserFilter::new("name").id(1))
216        .await
217        .unwrap();
218}

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§