1 use crate::{aggregates::site_aggregates::SiteAggregates, ToSafe};
2 use diesel::{result::Error, *};
4 schema::{site, site_aggregates, user_},
7 user::{UserSafe, User_},
12 #[derive(Debug, Serialize, Clone)]
15 pub creator: UserSafe,
16 pub counts: SiteAggregates,
20 pub fn read(conn: &PgConnection) -> Result<Self, Error> {
21 let (site, creator, counts) = site::table
22 .inner_join(user_::table)
23 .inner_join(site_aggregates::table)
26 User_::safe_columns_tuple(),
27 site_aggregates::all_columns,
29 .first::<(Site, UserSafe, SiteAggregates)>(conn)?;