Skip to main content

insert_many

Function insert_many 

Source
pub async fn insert_many<E>(
    _pool: &PgPool,
    entities: &[E],
    options: Option<BatchOptions>,
) -> BatchResult<BatchResultInfo>
where E: Entity + Debug + Send + Sync,
Expand description

Insert multiple entities in batches

This function inserts multiple entities in batches for better performance and to avoid statement size limits.

§Arguments

  • pool - The database connection pool
  • entities - The entities to insert
  • options - Optional batch operation settings

§Returns

Information about the batch operation

§Example

use ormkit::batch::insert_many;

let users = vec![/* ... */];
let result = insert_many(&pool, &users, None).await?;
println!("Inserted {} users", result.successful);