stuff happened
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
pub mod authors;
|
||||
pub mod comments;
|
||||
pub mod posts;
|
||||
pub mod projects;
|
||||
|
15
backend/public/src/datasources/projects.rs
Normal file
15
backend/public/src/datasources/projects.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use sqlx::{FromRow, Pool, Postgres, Row};
|
||||
|
||||
use crate::routes::projects::Project;
|
||||
|
||||
pub struct ProjectsDatasource;
|
||||
impl ProjectsDatasource {
|
||||
pub async fn get_all(pool: &Pool<Postgres>) -> Result<Vec<Project>, sqlx::Error> {
|
||||
sqlx::query_as!(
|
||||
Project,
|
||||
"SELECT project_id, title, repo, summary, tech, wip, created_at FROM projects p WHERE deleted_at IS NULL ORDER BY p.created_at DESC"
|
||||
)
|
||||
.fetch_all(pool)
|
||||
.await
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user