Skip to main content

max / makenotwork

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