2 schema::local_site::dsl::*,
4 utils::{get_conn, DbPool},
6 use diesel::{dsl::*, result::Error};
7 use diesel_async::RunQueryDsl;
10 pub async fn create(pool: &DbPool, form: &LocalSiteInsertForm) -> Result<Self, Error> {
11 let conn = &mut get_conn(pool).await?;
12 insert_into(local_site)
14 .get_result::<Self>(conn)
17 pub async fn read(pool: &DbPool) -> Result<Self, Error> {
18 let conn = &mut get_conn(pool).await?;
19 local_site.first::<Self>(conn).await
21 pub async fn update(pool: &DbPool, form: &LocalSiteUpdateForm) -> Result<Self, Error> {
22 let conn = &mut get_conn(pool).await?;
23 diesel::update(local_site)
25 .get_result::<Self>(conn)
28 pub async fn delete(pool: &DbPool) -> Result<usize, Error> {
29 let conn = &mut get_conn(pool).await?;
30 diesel::delete(local_site).execute(conn).await