- fn read(conn: &PgConnection, community_id: CommunityId) -> Result<Self, Error> {
- use crate::schema::community::dsl::*;
- community.find(community_id).first::<Self>(conn)
- }
-
- fn delete(conn: &PgConnection, community_id: CommunityId) -> Result<usize, Error> {
- use crate::schema::community::dsl::*;
- diesel::delete(community.find(community_id)).execute(conn)
- }
-
- fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result<Self, Error> {
- use crate::schema::community::dsl::*;
- insert_into(community)
- .values(new_community)
- .get_result::<Self>(conn)
- }
-
- fn update(
- conn: &PgConnection,
- community_id: CommunityId,
- new_community: &CommunityForm,
- ) -> Result<Self, Error> {
- use crate::schema::community::dsl::*;
- diesel::update(community.find(community_id))
- .set(new_community)
- .get_result::<Self>(conn)
- }
-}