use sqlx::{PgPool, Pool, Postgres}; use crate::routes::posts::Post; pub struct PostsDatasource; impl PostsDatasource { pub async fn get_all(pool: &Pool) -> Result, sqlx::Error> { sqlx::query_as::<_, Post>( "SELECT post_id, title, body, created_at FROM posts ORDER BY created_at DESC LIMIT 10", ) .fetch_all(pool) .await } pub async fn get_one(pool: PgPool, post_id: i32) {} }