]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/impls/local_site_rate_limit.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / db_schema / src / impls / local_site_rate_limit.rs
index b1af5f869193bf097d3dad3c1d211d90806c2514..0c9e96e0b45e0e600ad0c97f45b28b78f75587bb 100644 (file)
@@ -11,19 +11,25 @@ use diesel::{dsl::insert_into, result::Error};
 use diesel_async::RunQueryDsl;
 
 impl LocalSiteRateLimit {
-  pub async fn read(pool: &DbPool) -> Result<Self, Error> {
+  pub async fn read(pool: &mut DbPool<'_>) -> Result<Self, Error> {
     let conn = &mut get_conn(pool).await?;
     local_site_rate_limit::table.first::<Self>(conn).await
   }
 
-  pub async fn create(pool: &DbPool, form: &LocalSiteRateLimitInsertForm) -> Result<Self, Error> {
+  pub async fn create(
+    pool: &mut DbPool<'_>,
+    form: &LocalSiteRateLimitInsertForm,
+  ) -> Result<Self, Error> {
     let conn = &mut get_conn(pool).await?;
     insert_into(local_site_rate_limit::table)
       .values(form)
       .get_result::<Self>(conn)
       .await
   }
-  pub async fn update(pool: &DbPool, form: &LocalSiteRateLimitUpdateForm) -> Result<(), Error> {
+  pub async fn update(
+    pool: &mut DbPool<'_>,
+    form: &LocalSiteRateLimitUpdateForm,
+  ) -> Result<(), Error> {
     // avoid error "There are no changes to save. This query cannot be built"
     if form.is_empty() {
       return Ok(());