Rustango docs

Transactions & aggregates

Atomic writes, aggregates, and advanced query features.

Transactions

Wrap multiple writes in transaction_pool — the closure commits on Ok, rolls back on Err.

transaction_pool(&pool, |tx| async move {
    order.save_on(tx).await?;
    decrement_stock(tx, order.sku).await?;
    Ok(())
}).await?;

Aggregates & annotations

Querysets support count, sum, avg, min, max, window functions, and computed annotations — pushed down to SQL, not loaded into memory.

Bulk operations

bulk_insert / bulk_upsert write many rows in one statement; update_pool / delete_pool apply set-based changes without fetching.