2025-02-26 13:10:48 -08:00
|
|
|
use diesel::{
|
|
|
|
dsl::{auto_type, AsSelect},
|
|
|
|
pg::Pg,
|
|
|
|
prelude::*,
|
|
|
|
};
|
2025-02-26 13:10:50 -08:00
|
|
|
use uuid::Uuid;
|
|
|
|
|
2025-02-26 13:10:48 -08:00
|
|
|
use crate::{
|
|
|
|
schema::{self, projects::dsl::*},
|
|
|
|
teams::Team,
|
|
|
|
};
|
2025-02-26 13:10:50 -08:00
|
|
|
|
|
|
|
#[derive(Associations, Clone, Debug, Identifiable, Insertable, Queryable, Selectable)]
|
|
|
|
#[diesel(table_name = schema::projects)]
|
|
|
|
#[diesel(belongs_to(Team))]
|
|
|
|
pub struct Project {
|
|
|
|
pub id: Uuid,
|
|
|
|
pub team_id: Uuid,
|
|
|
|
pub name: String,
|
|
|
|
}
|
2025-02-26 13:10:48 -08:00
|
|
|
|
|
|
|
impl Project {
|
|
|
|
#[auto_type(no_type_alias)]
|
|
|
|
pub fn all() -> _ {
|
|
|
|
let select: AsSelect<Project, Pg> = Project::as_select();
|
|
|
|
projects.select(select)
|
|
|
|
}
|
|
|
|
}
|