feat: read_all for post, post_interaction, comment_interaction, comment

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-12-05 02:47:51 +03:00
parent dca2abb62a
commit 1aa1d8cb1e
4 changed files with 60 additions and 0 deletions

View file

@ -72,3 +72,18 @@ pub async fn delete(
.fetch_one(database_connection)
.await
}
pub async fn read_all(
post_creation_time: DateTime<Utc>,
database_connection: &Pool<Postgres>,
) -> Result<Vec<Comment>, sqlx::Error> {
sqlx::query_as!(
Comment,
r#"
SELECT * FROM "comment" WHERE "post_creation_time" = $1
"#,
post_creation_time
)
.fetch_all(database_connection)
.await
}

View file

@ -72,3 +72,18 @@ pub async fn delete(
.fetch_one(database_connection)
.await
}
pub async fn read_all(
comment_creation_time: &DateTime<Utc>,
database_connection: &Pool<Postgres>,
) -> Result<Vec<CommentInteraction>, sqlx::Error> {
sqlx::query_as!(
CommentInteraction,
r#"
SELECT * FROM "comment_interaction" WHERE "comment_creation_time" = $1
"#,
comment_creation_time
)
.fetch_all(database_connection)
.await
}

View file

@ -72,3 +72,18 @@ pub async fn delete(
.fetch_one(database_connection)
.await
}
pub async fn read_all(
poster_id: i64,
database_connection: &Pool<Postgres>,
) -> Result<Vec<Post>, sqlx::Error> {
sqlx::query_as!(
Post,
r#"
SELECT * FROM "post" WHERE "poster_id" = $1
"#,
poster_id
)
.fetch_all(database_connection)
.await
}

View file

@ -72,3 +72,18 @@ pub async fn delete(
.fetch_one(database_connection)
.await
}
pub async fn read_all(
post_creation_time: &DateTime<Utc>,
database_connection: &Pool<Postgres>,
) -> Result<Vec<PostInteraction>, sqlx::Error> {
sqlx::query_as!(
PostInteraction,
r#"
SELECT * FROM "post_interaction" WHERE "post_creation_time" = $1
"#,
post_creation_time
)
.fetch_all(database_connection)
.await
}