use diesel::{ExpressionMethods, Insertable, QueryDsl, Queryable, RunQueryDsl}; use serde::{Serialize, Deserialize}; use uuid::Uuid; use crate::schema::gamenight_participant; use super::error::DatabaseError; use super::DbConnection; #[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 get_participants(conn: &mut DbConnection, id: &Uuid) -> Result<Vec<Uuid>, DatabaseError> { Ok(gamenight_participant::table .filter(gamenight_participant::gamenight_id.eq(&id)) .select(gamenight_participant::user_id) .get_results(conn)?) }