added nested routes, added separate config struct, among other items

This commit is contained in:
2024-09-24 20:26:15 -04:00
parent cf199ab48a
commit 845f058568
7 changed files with 164 additions and 23 deletions

View File

@@ -1,2 +1,8 @@
use crate::routes::comments::CommentInput;
use sqlx::PgPool;
pub struct CommentsDatasource;
impl CommentsDatasource {}
impl CommentsDatasource {
pub async fn get_posts_comments(pool: PgPool) {}
pub async fn insert_comment(pool: PgPool, comment_input: CommentInput) {}
}

View File

@@ -1,2 +1,11 @@
use sqlx::PgPool;
pub struct PostsDatasource;
impl PostsDatasource {}
impl PostsDatasource {
pub async fn get_all(pool: PgPool) {
sqlx::query("SELECT title, body, created_at FROM posts ORDER BY created_at DESC LIMIT 10")
.fetch_all(&pool)
.await;
}
pub async fn get_one(pool: PgPool) {}
}