use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use sqlx::{Pool, Postgres}; use crate::database::post; #[derive(Debug, Serialize, Deserialize)] pub struct Post { pub creation_time: DateTime, pub user_id: i64, pub post: String, } impl Post { pub async fn create( user_id: &i64, post: &String, database_connection: &Pool, ) -> Result { post::create(user_id, post, database_connection).await } pub async fn read( creation_time: &DateTime, database_connection: &Pool, ) -> Result { post::read(creation_time, database_connection).await } pub async fn update( creation_time: &DateTime, user_id: &i64, post: &String, database_connection: &Pool, ) -> Result { post::update(creation_time, user_id, post, database_connection).await } pub async fn delete( creation_time: &DateTime, database_connection: &Pool, ) -> Result { post::delete(creation_time, database_connection).await } pub async fn read_all(database_connection: &Pool) -> Result, sqlx::Error> { post::read_all(database_connection).await } pub async fn read_all_for_user( user_id: &i64, database_connection: &Pool, ) -> Result, sqlx::Error> { post::read_all_for_user(user_id, database_connection).await } }