Skip to main content

max / makenotwork

570 B · 24 lines History Blame Raw
1 use super::{PgPool, Uuid};
2
3 /// Insert a footnote on a post. Returns the footnote ID.
4 #[tracing::instrument(skip_all)]
5 pub async fn insert_footnote(
6 pool: &PgPool,
7 post_id: Uuid,
8 author_id: Uuid,
9 body_markdown: &str,
10 body_html: &str,
11 ) -> Result<Uuid, sqlx::Error> {
12 sqlx::query_scalar!(
13 "INSERT INTO post_footnotes (post_id, author_id, body_markdown, body_html)
14 VALUES ($1, $2, $3, $4)
15 RETURNING id",
16 post_id,
17 author_id,
18 body_markdown,
19 body_html,
20 )
21 .fetch_one(pool)
22 .await
23 }
24