Trait atmosphere::Update
source · pub trait Update: Table + Bind + Hooks + Send + Sync + Unpin + 'static {
// Required methods
fn update<'e, 'life0, 'async_trait, E>(
&'life0 mut self,
executor: E
) -> Pin<Box<dyn Future<Output = Result<<Postgres as Database>::QueryResult, Error>> + Send + 'async_trait>>
where 'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait;
fn save<'e, 'life0, 'async_trait, E>(
&'life0 mut self,
executor: E
) -> Pin<Box<dyn Future<Output = Result<<Postgres as Database>::QueryResult, Error>> + Send + 'async_trait>>
where 'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait;
}
Expand description
Update rows in a database.
Provides functionality for updating data in tables within a SQL database. This trait defines asynchronous methods for modifying existing rows in the database, either through direct updates or upserts (update or insert if not exists). It ensures that hooks are executed at various stages, enabling custom logic to be integrated into the update process.
Required Methods§
sourcefn update<'e, 'life0, 'async_trait, E>(
&'life0 mut self,
executor: E
) -> Pin<Box<dyn Future<Output = Result<<Postgres as Database>::QueryResult, Error>> + Send + 'async_trait>>where
'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait,
fn update<'e, 'life0, 'async_trait, E>(
&'life0 mut self,
executor: E
) -> Pin<Box<dyn Future<Output = Result<<Postgres as Database>::QueryResult, Error>> + Send + 'async_trait>>where
'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait,
Updates an existing row in the database. This method constructs an update query, binds the necessary values, executes the query, and applies hooks at predefined stages (e.g., before binding, before execution, after execution).
sourcefn save<'e, 'life0, 'async_trait, E>(
&'life0 mut self,
executor: E
) -> Pin<Box<dyn Future<Output = Result<<Postgres as Database>::QueryResult, Error>> + Send + 'async_trait>>where
'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait,
fn save<'e, 'life0, 'async_trait, E>(
&'life0 mut self,
executor: E
) -> Pin<Box<dyn Future<Output = Result<<Postgres as Database>::QueryResult, Error>> + Send + 'async_trait>>where
'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait,
Similar to update
, but uses an upsert approach. It either updates an existing row or
inserts a new one if it does not exist, depending on the primary key’s presence and
uniqueness.