2 aggregates::structs::{PersonPostAggregates, PersonPostAggregatesForm},
3 newtypes::{PersonId, PostId},
5 use diesel::{result::Error, *};
7 impl PersonPostAggregates {
8 pub fn upsert(conn: &mut PgConnection, form: &PersonPostAggregatesForm) -> Result<Self, Error> {
9 use crate::schema::person_post_aggregates::dsl::*;
10 insert_into(person_post_aggregates)
12 .on_conflict((person_id, post_id))
15 .get_result::<Self>(conn)
18 conn: &mut PgConnection,
21 ) -> Result<Self, Error> {
22 use crate::schema::person_post_aggregates::dsl::*;
23 person_post_aggregates
24 .filter(post_id.eq(post_id_).and(person_id.eq(person_id_)))