feat: ✨ read all posts and read all posts for user
This commit is contained in:
parent
1aa1d8cb1e
commit
0a6780a1de
1 changed files with 13 additions and 0 deletions
|
@ -74,6 +74,19 @@ pub async fn delete(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn read_all(
|
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,
|
poster_id: i64,
|
||||||
database_connection: &Pool<Postgres>,
|
database_connection: &Pool<Postgres>,
|
||||||
) -> Result<Vec<Post>, sqlx::Error> {
|
) -> Result<Vec<Post>, sqlx::Error> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue