3 schema::registration_application::dsl::{local_user_id, registration_application},
4 source::registration_application::{
5 RegistrationApplication,
6 RegistrationApplicationInsertForm,
7 RegistrationApplicationUpdateForm,
10 utils::{get_conn, DbPool},
12 use diesel::{insert_into, result::Error, ExpressionMethods, QueryDsl};
13 use diesel_async::RunQueryDsl;
16 impl Crud for RegistrationApplication {
17 type InsertForm = RegistrationApplicationInsertForm;
18 type UpdateForm = RegistrationApplicationUpdateForm;
21 async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
22 let conn = &mut get_conn(pool).await?;
23 insert_into(registration_application)
25 .get_result::<Self>(conn)
30 pool: &mut DbPool<'_>,
32 form: &Self::UpdateForm,
33 ) -> Result<Self, Error> {
34 let conn = &mut get_conn(pool).await?;
35 diesel::update(registration_application.find(id_))
37 .get_result::<Self>(conn)
42 impl RegistrationApplication {
43 pub async fn find_by_local_user_id(
44 pool: &mut DbPool<'_>,
45 local_user_id_: LocalUserId,
46 ) -> Result<Self, Error> {
47 let conn = &mut get_conn(pool).await?;
48 registration_application
49 .filter(local_user_id.eq(local_user_id_))