]> Untitled Git - lemmy.git/blob - crates/db_schema/src/impls/secret.rs
4e0d9c1bdf0628805b9443e5f7bcb39ff4b59bc5
[lemmy.git] / crates / db_schema / src / impls / secret.rs
1 use crate::{
2   schema::secret::dsl::secret,
3   source::secret::Secret,
4   utils::{get_conn, DbPool},
5 };
6 use diesel::result::Error;
7 use diesel_async::RunQueryDsl;
8
9 impl Secret {
10   /// Initialize the Secrets from the DB.
11   /// Warning: You should only call this once.
12   pub async fn init(pool: &DbPool) -> Result<Secret, Error> {
13     Self::read_secrets(pool).await
14   }
15
16   async fn read_secrets(pool: &DbPool) -> Result<Secret, Error> {
17     let conn = &mut get_conn(pool).await?;
18     secret.first::<Secret>(conn).await
19   }
20 }