2 schema::community_block::dsl::{community_block, community_id, person_id},
3 source::community_block::{CommunityBlock, CommunityBlockForm},
5 utils::{get_conn, DbPool},
7 use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
8 use diesel_async::RunQueryDsl;
11 impl Blockable for CommunityBlock {
12 type Form = CommunityBlockForm;
13 async fn block(pool: &mut DbPool<'_>, community_block_form: &Self::Form) -> Result<Self, Error> {
14 let conn = &mut get_conn(pool).await?;
15 insert_into(community_block)
16 .values(community_block_form)
17 .on_conflict((person_id, community_id))
19 .set(community_block_form)
20 .get_result::<Self>(conn)
24 pool: &mut DbPool<'_>,
25 community_block_form: &Self::Form,
26 ) -> Result<usize, Error> {
27 let conn = &mut get_conn(pool).await?;
30 .filter(person_id.eq(community_block_form.person_id))
31 .filter(community_id.eq(community_block_form.community_id)),