lemmy/crates/db_schema/src/impls/secret.rs
Nutomic 6f3bf4634b
Various pedantic clippy fixes (#2568)
* Various pedantic clippy fixes

* more clippy pedantic fixes

* try to fix ci

* add fix clippy script, use rust 1.65

* fix clippy
2022-11-19 04:33:54 +00:00

21 lines
520 B
Rust

use crate::{
schema::secret::dsl::secret,
source::secret::Secret,
utils::{get_conn, DbPool},
};
use diesel::result::Error;
use diesel_async::RunQueryDsl;
impl Secret {
/// Initialize the Secrets from the DB.
/// Warning: You should only call this once.
pub async fn init(pool: &DbPool) -> Result<Secret, Error> {
Self::read_secrets(pool).await
}
async fn read_secrets(pool: &DbPool) -> Result<Secret, Error> {
let conn = &mut get_conn(pool).await?;
secret.first::<Secret>(conn).await
}
}