feat: add reply functionality to thoughts, including database migration and tests

This commit is contained in:
2025-09-06 16:58:11 +02:00
parent 728bf0e231
commit 0abd275946
7 changed files with 96 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ pub async fn create_thought(
let new_thought = thought::ActiveModel {
author_id: Set(author_id),
content: Set(params.content.clone()),
reply_to_id: Set(params.reply_to_id),
..Default::default()
}
.insert(&txn)
@@ -56,6 +57,7 @@ pub async fn get_thoughts_by_user(
.select_only()
.column(thought::Column::Id)
.column(thought::Column::Content)
.column(thought::Column::ReplyToId)
.column(thought::Column::CreatedAt)
.column(thought::Column::AuthorId)
.column_as(user::Column::Username, "author_username")
@@ -79,6 +81,7 @@ pub async fn get_feed_for_user(
.select_only()
.column(thought::Column::Id)
.column(thought::Column::Content)
.column(thought::Column::ReplyToId)
.column(thought::Column::CreatedAt)
.column(thought::Column::AuthorId)
.column_as(user::Column::Username, "author_username")
@@ -99,6 +102,7 @@ pub async fn get_thoughts_by_tag_name(
.select_only()
.column(thought::Column::Id)
.column(thought::Column::Content)
.column(thought::Column::ReplyToId)
.column(thought::Column::CreatedAt)
.column(thought::Column::AuthorId)
.column_as(user::Column::Username, "author_username")