use crate::{
error::*, ActiveModelTrait, ConnectionTrait, EntityTrait, Statement, UpdateMany, UpdateOne,
};
use sea_query::UpdateStatement;
use std::future::Future;
#[derive(Clone, Debug)]
pub struct Updater {
query: UpdateStatement,
}
#[derive(Clone, Debug)]
pub struct UpdateResult {
pub rows_affected: u64,
}
impl<'a, A: 'a> UpdateOne
where
A: ActiveModelTrait,
{
pub async fn exec<'b, C>(self, db: &'b C) -> Result
where
C: ConnectionTrait<'b>,
{
// so that self is dropped before entering await
exec_update_and_return_original(self.query, self.model, db).await
}
}
impl<'a, E> UpdateMany
where
E: EntityTrait,
{
pub fn exec(self, db: &'a C) -> impl Future