use crate::{ schema::local_site_rate_limit, source::local_site_rate_limit::*, utils::{get_conn, DbPool}, }; use diesel::{dsl::*, result::Error}; use diesel_async::RunQueryDsl; impl LocalSiteRateLimit { pub async fn read(pool: &DbPool) -> Result { let conn = &mut get_conn(pool).await?; local_site_rate_limit::table.first::(conn).await } pub async fn create(pool: &DbPool, form: &LocalSiteRateLimitInsertForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(local_site_rate_limit::table) .values(form) .get_result::(conn) .await } pub async fn update(pool: &DbPool, form: &LocalSiteRateLimitUpdateForm) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(local_site_rate_limit::table) .set(form) .get_result::(conn) .await } }