feat: read all posts and read all posts for user

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-12-05 02:49:54 +03:00
parent 1aa1d8cb1e
commit 0a6780a1de

View file

@ -74,6 +74,19 @@ pub async fn delete(
}
pub async fn read_all(
database_connection: &Pool<Postgres>,
) -> Result<Vec<Post>, sqlx::Error> {
sqlx::query_as!(
Post,
r#"
SELECT * FROM "post"
"#,
)
.fetch_all(database_connection)
.await
}
pub async fn read_all_for_user(
poster_id: i64,
database_connection: &Pool<Postgres>,
) -> Result<Vec<Post>, sqlx::Error> {