lemmy/lemmy_db/src/site_aggregates.rs

20 lines
465 B
Rust
Raw Normal View History

2020-12-03 03:39:31 +00:00
use crate::schema::site_aggregates;
use diesel::{result::Error, *};
use serde::Serialize;
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)]
#[table_name = "site_aggregates"]
pub struct SiteAggregates {
pub id: i32,
pub users: i64,
pub posts: i64,
pub comments: i64,
pub communities: i64,
}
impl SiteAggregates {
pub fn read(conn: &PgConnection) -> Result<Self, Error> {
site_aggregates::table.first::<Self>(conn)
}
}