Splits database into a separate crate

This commit is contained in:
2025-05-30 14:31:00 +02:00
parent 3f7ed03973
commit 597a960bf1
34 changed files with 368 additions and 402 deletions
@@ -0,0 +1,22 @@
use diesel::{ExpressionMethods, Insertable, PgConnection, QueryDsl, Queryable, RunQueryDsl};
use serde::{Serialize, Deserialize};
use uuid::Uuid;
use crate::schema::gamenight_participant;
use super::error::DatabaseError;
#[derive(Serialize, Deserialize, Debug, Insertable, Queryable)]
#[diesel(belongs_to(Gamenight))]
#[diesel(belongs_to(User))]
#[diesel(table_name = gamenight_participant)]
pub struct GamenightParticipants {
pub gamenight_id: Uuid,
pub user_id: Uuid,
}
pub fn gamenight_participants(conn: &mut PgConnection, id: Uuid) -> Result<Vec<GamenightParticipants>, DatabaseError> {
Ok(gamenight_participant::table
.filter(gamenight_participant::gamenight_id.eq(id))
.get_results(conn)?)
}