summaryrefslogtreecommitdiff
path: root/src/db/mod.rs
blob: f1baf44306d34210cc59f8f73fad03ca5edbd0a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use sqlx::SqlitePool;

use crate::error::AppError;
use async_trait::async_trait;

pub mod game;
pub mod product;
pub mod producttag;
pub mod story;
pub mod tag;
pub mod tool;

#[async_trait]
pub trait ProductDatabaseHandler {
    async fn get_all(pool: &SqlitePool) -> Result<Vec<Self>, AppError>
    where
        Self: Sized;

    async fn post(
        &self,
        pool: &SqlitePool,
        name: &str,
        description: &str,
        tags: Vec<&str>,
    ) -> Result<Self, AppError>
    where
        Self: Sized;

    async fn delete(pool: &SqlitePool, id: i64) -> Result<(), AppError>
    where
        Self: Sized;
}