Function create_org

Source
pub async fn create_org(pool: &Pool<MySql>, name: &str) -> Result<Org>
Expand description

Creates a new organization in the system.

This function inserts a new organization record with the provided name. It uses a transaction to ensure data consistency during the creation process.

§Arguments

  • pool - Database connection pool for executing the query
  • name - Name of the new organization

§Returns

  • Ok(Org) - Successfully created organization record
  • Err(anyhow::Error) - Failed to create organization record

§Transaction Handling

This function uses a database transaction to ensure atomicity of the operation. If any part of the operation fails, the entire operation is rolled back.

§Note

The created organization will have system-generated values for:

  • id - Auto-incremented primary key
  • created_at - Timestamp of creation
  • updated_at - Initially same as creation timestamp