]> Untitled Git - lemmy.git/blobdiff - crates/db_views_actor/src/community_view.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / db_views_actor / src / community_view.rs
index 7f05afca9068272cbfaa379683ad96f32098b28f..74aba52f2267d7ec93da7c56e633f3342bd34525 100644 (file)
@@ -34,7 +34,7 @@ type CommunityViewTuple = (
 
 impl CommunityView {
   pub async fn read(
-    pool: &DbPool,
+    pool: &mut DbPool<'_>,
     community_id: CommunityId,
     my_person_id: Option<PersonId>,
     is_mod_or_admin: Option<bool>,
@@ -86,7 +86,7 @@ impl CommunityView {
   }
 
   pub async fn is_mod_or_admin(
-    pool: &DbPool,
+    pool: &mut DbPool<'_>,
     person_id: PersonId,
     community_id: CommunityId,
   ) -> Result<bool, Error> {
@@ -102,9 +102,9 @@ impl CommunityView {
 
 #[derive(TypedBuilder)]
 #[builder(field_defaults(default))]
-pub struct CommunityQuery<'a> {
+pub struct CommunityQuery<'a, 'b: 'a> {
   #[builder(!default)]
-  pool: &'a DbPool,
+  pool: &'a mut DbPool<'b>,
   listing_type: Option<ListingType>,
   sort: Option<SortType>,
   local_user: Option<&'a LocalUser>,
@@ -115,7 +115,7 @@ pub struct CommunityQuery<'a> {
   limit: Option<i64>,
 }
 
-impl<'a> CommunityQuery<'a> {
+impl<'a, 'b: 'a> CommunityQuery<'a, 'b> {
   pub async fn list(self) -> Result<Vec<CommunityView>, Error> {
     use SortType::*;