diff --git a/crates/db_schema/src/traits.rs b/crates/db_schema/src/traits.rs index 3f62f81ae..ff2a51bb5 100644 --- a/crates/db_schema/src/traits.rs +++ b/crates/db_schema/src/traits.rs @@ -41,7 +41,7 @@ pub type InsertValues<'a, 'b, T> = #[async_trait] pub trait Crud<'a> where - Self: HasTable + Sized, + Self: HasTable + Sized + Send, for<'b> Self::Table: FindDsl<>::IdType> + 'static, for<'b> Find<'b, Self>: LimitDsl + Send + IntoUpdateTarget + 'static, for<'b> dsl::Limit>: Send + LoadQuery<'static, AsyncPgConnection, Self> + 'static, @@ -52,8 +52,8 @@ where for<'b> as HasTable>::Table: 'static + Send, for<'b> &'a >::InsertForm: Insertable, for<'b> InsertValues<'a, 'b, Self>: 'a, - for<'b, 'query> InsertStatement>: - LoadQuery<'query, AsyncPgConnection, Self> + 'query + Send, + for<'b> InsertStatement>: + LoadQuery<'a, AsyncPgConnection, Self> + 'a + Send, { type InsertForm: 'static + Send + Sync; type UpdateForm: 'static + Send + Sync; @@ -63,18 +63,23 @@ where + Sized + Send + AsExpression<<::PrimaryKey as Expression>::SqlType>; - async fn create<'life0, 'life1>( + fn create<'life0, 'life1, 'async_trait>( pool: &'life0 mut DbPool<'life1>, form: &'a Self::InsertForm, - ) -> Result - //Pin> + Send + 'async_trait>> + ) -> Pin> + Send + 'async_trait>> where 'a: 'async_trait, + 'life0: 'async_trait, + 'life1: 'async_trait, + Self: Sized + 'async_trait, { let query = insert_into(Self::table()).values(form); - let conn = &mut *get_conn(pool).await?; - query.get_result::(conn).await - //Box::pin(get_conn(pool).and_then(move |mut conn| query.get_result::(&mut *conn))) + //let conn = &mut *get_conn(pool).await?; + //query.get_result::(conn).await + Box::pin( + get_conn(pool) + .and_then(move |mut conn| async move { query.get_result::(&mut *conn).await }), + ) } async fn read(pool: &mut DbPool<'_>, id: Self::IdType) -> Result where