feat: init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
|
||||
pub struct UserProfile {
|
||||
pub user_id: Uuid,
|
||||
pub full_name: Option<String>,
|
||||
pub company: Option<String>,
|
||||
pub location: Option<String>,
|
||||
pub website_url: Option<String>,
|
||||
pub twitter_username: Option<String>,
|
||||
pub timezone: Option<String>,
|
||||
pub language: Option<String>,
|
||||
pub profile_readme: Option<String>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
impl UserProfile {
|
||||
pub async fn find_by_user_id(
|
||||
pool: &sqlx::PgPool,
|
||||
user_id: Uuid,
|
||||
) -> Result<Option<Self>, sqlx::Error> {
|
||||
sqlx::query_as::<_, UserProfile>(
|
||||
"SELECT user_id, full_name, company, location, website_url, twitter_username, \
|
||||
timezone, language, profile_readme, created_at, updated_at \
|
||||
FROM user_profile WHERE user_id = $1",
|
||||
)
|
||||
.bind(user_id)
|
||||
.fetch_optional(pool)
|
||||
.await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user