db works fine, now to do more useful stuff

This commit is contained in:
Artémis 2025-01-11 16:30:48 +01:00
parent 937797f5b7
commit 13e7e98b8c

View file

@ -39,8 +39,42 @@ struct TagForm {
}
#[post("/register", data = "<tag>")]
fn handle_register(tag: Form<TagForm>) -> Template {
async fn handle_register(mut db: Connection<DollTags>, tag: Form<TagForm>) -> Template {
println!("register: {:?}", tag);
let pronouns = format!(
"{}/{}/{}",
tag.pronoun_subject, tag.pronoun_object, tag.pronoun_possessive
);
sqlx::query!(
r#"
insert into doll_profiles
(id,
name, pronouns, handler_name, handler_url,
kind, breed, behaviour,
description, chassis_type, chassis_id, chassis_color, microchipped
)
values
(?,
?, ?, ?, ?,
?, ?, ?,
?, ?, ?, ?, ?)"#,
tag.ident,
tag.name,
pronouns,
tag.handler_name,
tag.handler_link,
tag.kind,
tag.breed,
tag.behaviour,
"",
"",
"",
"",
1
)
.execute(&mut **db)
.await
.expect("fuck");
Template::render("register", context! {})
}
@ -51,14 +85,17 @@ async fn show_profile(mut db: Connection<DollTags>, ident: &str) -> Template {
pub id: i64,
pub created_at: chrono::NaiveDateTime,
}
sqlx::query_as!(
let profile = sqlx::query_as!(
Tag,
r#"select id, created_at as "created_at!: chrono::NaiveDateTime" from doll_profiles"#
r#"select id, created_at as "created_at!: chrono::NaiveDateTime" from doll_profiles where id = ?"#,
423158
)
.fetch_one(&mut **db)
.await
.expect("fuck");
println!("{:?}", profile);
Template::render(
"show_profile",
context! {