Skip to main content

update_many

Function update_many 

Source
pub async fn update_many<P>(
    pool: &PgPool,
    table: &str,
    updates: &[(&str, &str)],
    condition: &str,
    params: &[P],
    _options: Option<BatchOptions>,
) -> BatchResult<u64>
where P: for<'r> Encode<'r, Postgres> + Type<Postgres> + Clone + Sync + Send,
Expand description

Update multiple entities in batches

This function updates multiple entities in batches for better performance.

§Arguments

  • pool - The database connection pool
  • updates - Tuple of (column, value, condition) updates
  • options - Optional batch operation settings

§Returns

Information about the batch operation

§Example

use ormkit::batch::update_many;

// Update all active users to have status='verified'
let result = update_many(
    &pool,
    "users",
    &[("status", "verified")],
    "status = $1",
    &[&"active" as &(dyn sqlx::Encode<sqlx::Postgres> + sqlx::Type<sqlx::Postgres> + Sync + Send)],
    None
).await?;