mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-15 08:54:01 +00:00
27 lines
583 B
Rust
27 lines
583 B
Rust
use crate::{
|
|
source::{
|
|
site::Site,
|
|
user::{UserSafe, User_},
|
|
},
|
|
ToSafe,
|
|
};
|
|
use diesel::{result::Error, *};
|
|
use lemmy_db_schema::schema::{site, user_};
|
|
use serde::Serialize;
|
|
|
|
#[derive(Debug, Serialize, Clone)]
|
|
pub struct SiteView {
|
|
pub site: Site,
|
|
pub creator: UserSafe,
|
|
}
|
|
|
|
impl SiteView {
|
|
pub fn read(conn: &PgConnection) -> Result<Self, Error> {
|
|
let (site, creator) = site::table
|
|
.inner_join(user_::table)
|
|
.select((site::all_columns, User_::safe_columns_tuple()))
|
|
.first::<(Site, UserSafe)>(conn)?;
|
|
|
|
Ok(SiteView { site, creator })
|
|
}
|
|
}
|