pub async fn update_user_profile(
db: &DB,
payload: &UpdateUserProfileRequest,
) -> Result<User, (StatusCode, String)>Expand description
Updates a user’s profile information in the database
§Arguments
db- A reference to the database connectionuser_id- The ID of the user whose profile is being updatedemail- The new email address for the userusername- The new username for the user
§Returns
Ok(User)- The updated user object if the operation was successfulErr((StatusCode, String))- An error if the operation failed, containing an HTTP status code and an error message
§Example
use crate::db::DB;
use crate::db::queries::auth;
async fn example_update_user_profile(db: &DB) {
let user_id = "user_id";
let new_email = "test@example.com";
let new_username = "new_username";
match auth::update_user_profile(db, user_id, new_email, new_username).await {
Ok(user) => println!("User profile updated: {:?}", user),
Err((status, message)) => eprintln!("Error updating user profile ({}): {}", status, message),
}
}