From 469a3ad33914f7eff6edc9ca7fabb12f2950da84 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 14 Nov 2024 17:59:21 +0000 Subject: database work --- src/comment.rs | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/comment.rs') diff --git a/src/comment.rs b/src/comment.rs index 77b0fc0..55c4607 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -1,12 +1,34 @@ +use time::OffsetDateTime; + +use crate::error::Error; +use crate::Result; + +#[derive(sqlx::FromRow)] pub struct Comment { /// id of the comment in the thread - id: Option, + id: Option, /// text of the comment - text: String, - /// thread comment is in - thread: usize, + pub text: String, + /// id of artwork thread comment is in + pub artwork_id: i32, + /// comment creation time + created_at: Option, /// comments that are mentioned by the comment - in_reply_to: Vec, + pub in_reply_to_ids: Vec, /// comments that mention the comment - mentioned_by: Vec, + mentioned_by_ids: Vec, +} + +impl Comment { + pub fn id(&self) -> Option { + self.id + } + + pub fn created_at(&self) -> Option { + self.created_at + } + + pub fn mentioned_by_ids(&self) -> &Vec { + &self.mentioned_by_ids + } } -- cgit