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 queryname- Name of the new organization
§Returns
Ok(Org)- Successfully created organization recordErr(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 keycreated_at- Timestamp of creationupdated_at- Initially same as creation timestamp