forked from Roflin/gamenight
Returns participants for a gamenight
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
use diesel::{ExpressionMethods, Insertable, PgConnection, QueryDsl, Queryable, RunQueryDsl};
|
||||
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))]
|
||||
@@ -15,8 +16,9 @@ pub struct GamenightParticipants {
|
||||
pub user_id: Uuid,
|
||||
}
|
||||
|
||||
pub fn gamenight_participants(conn: &mut PgConnection, id: Uuid) -> Result<Vec<GamenightParticipants>, DatabaseError> {
|
||||
pub fn get_participants(conn: &mut DbConnection, id: &Uuid) -> Result<Vec<Uuid>, DatabaseError> {
|
||||
Ok(gamenight_participant::table
|
||||
.filter(gamenight_participant::gamenight_id.eq(id))
|
||||
.filter(gamenight_participant::gamenight_id.eq(&id))
|
||||
.select(gamenight_participant::user_id)
|
||||
.get_results(conn)?)
|
||||
}
|
||||
@@ -16,7 +16,7 @@ use diesel_migrations::MigrationHarness;
|
||||
pub use user::login;
|
||||
pub use user::register;
|
||||
pub use gamenight::gamenights;
|
||||
pub use gamenight_participants::gamenight_participants;
|
||||
pub use gamenight_participants::get_participants;
|
||||
|
||||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
|
||||
pub type DbConnection = PgConnection;
|
||||
|
||||
Reference in New Issue
Block a user