use diesel::pg::Pg;
use diesel::prelude::*;
use diesel::{debug_query, QueryResult};
use diesel_async::{AsyncPgConnection, RunQueryDsl};
use log::debug;
use crate::model::dto::ApplicationSettingDto;
use crate::model::entity::ApplicationSetting;
use crate::schema::application_settings::{self, key as key_column};
impl ApplicationSetting {
pub async fn find_by_key(
key: &str,
conn: &mut AsyncPgConnection,
) -> QueryResult<ApplicationSettingDto> {
let query = application_settings::table.filter(key_column.eq(key));
debug!("{}", debug_query::<Pg, _>(&query));
query.first::<Self>(conn).await.map(Into::into)
}
}