]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/impls/custom_emoji.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / db_schema / src / impls / custom_emoji.rs
index cce35dfc75d1c7acdd203c60c4f0ba6094da0f44..050301659462a7868c6fba5d02d1c5cb29bb1d54 100644 (file)
@@ -14,7 +14,7 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
 use diesel_async::RunQueryDsl;
 
 impl CustomEmoji {
-  pub async fn create(pool: &DbPool, form: &CustomEmojiInsertForm) -> Result<Self, Error> {
+  pub async fn create(pool: &mut DbPool<'_>, form: &CustomEmojiInsertForm) -> Result<Self, Error> {
     let conn = &mut get_conn(pool).await?;
     insert_into(custom_emoji)
       .values(form)
@@ -22,7 +22,7 @@ impl CustomEmoji {
       .await
   }
   pub async fn update(
-    pool: &DbPool,
+    pool: &mut DbPool<'_>,
     emoji_id: CustomEmojiId,
     form: &CustomEmojiUpdateForm,
   ) -> Result<Self, Error> {
@@ -32,7 +32,7 @@ impl CustomEmoji {
       .get_result::<Self>(conn)
       .await
   }
-  pub async fn delete(pool: &DbPool, emoji_id: CustomEmojiId) -> Result<usize, Error> {
+  pub async fn delete(pool: &mut DbPool<'_>, emoji_id: CustomEmojiId) -> Result<usize, Error> {
     let conn = &mut get_conn(pool).await?;
     diesel::delete(custom_emoji.find(emoji_id))
       .execute(conn)
@@ -42,7 +42,7 @@ impl CustomEmoji {
 
 impl CustomEmojiKeyword {
   pub async fn create(
-    pool: &DbPool,
+    pool: &mut DbPool<'_>,
     form: Vec<CustomEmojiKeywordInsertForm>,
   ) -> Result<Vec<Self>, Error> {
     let conn = &mut get_conn(pool).await?;
@@ -51,7 +51,7 @@ impl CustomEmojiKeyword {
       .get_results::<Self>(conn)
       .await
   }
-  pub async fn delete(pool: &DbPool, emoji_id: CustomEmojiId) -> Result<usize, Error> {
+  pub async fn delete(pool: &mut DbPool<'_>, emoji_id: CustomEmojiId) -> Result<usize, Error> {
     let conn = &mut get_conn(pool).await?;
     diesel::delete(custom_emoji_keyword.filter(custom_emoji_id.eq(emoji_id)))
       .execute(conn)