pub async fn delete_user_by_id(
db: &DB,
user_id: &str,
) -> Result<(), Box<dyn Error + Send + Sync>>Expand description
Deletes a user from the database by their ID
§Arguments
db- A reference to the database connectionuser_id- The ID of the user to delete
§Returns
Ok(())- If the user was successfully deletedErr(Box<dyn Error>)- An error if the operation failed, such as if there was a database error
§Errors
- “Failed to delete user” - If the database query did not execute successfully, indicating that the user could not be deleted
§Example
use crate::db::DB;
use crate::db::queries::auth;
async fn example_delete_user(db: &DB) {
let user_id = "user_id_to_delete";
match auth::delete_user_by_id(db, user_id).await {
Ok(()) => println!("User deleted successfully"),
Err(e) => eprintln!("Error deleting user: {}", e),
}
}