use diesel::{result::Error, *}; use lemmy_db_schema::schema::comment_aggregates; use serde::Serialize; #[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)] #[table_name = "comment_aggregates"] pub struct CommentAggregates { pub id: i32, pub comment_id: i32, pub score: i64, pub upvotes: i64, pub downvotes: i64, } impl CommentAggregates { pub fn read(conn: &PgConnection, comment_id: i32) -> Result { comment_aggregates::table .filter(comment_aggregates::comment_id.eq(comment_id)) .first::(conn) } } // TODO add tests here