mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-23 18:01:00 +00:00
Simplify Crud::read lifetimes
This commit is contained in:
parent
1f108177d0
commit
8745a6cc45
1 changed files with 4 additions and 4 deletions
|
@ -67,14 +67,14 @@ where
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}*/
|
}*/
|
||||||
async fn read<'conn, 'conn2: 'conn, 'a: 'conn>(pool: &'conn2 mut DbPool<'a>, id: Self::IdType) -> Result<Self, Error>
|
async fn read(pool: &'async_trait mut DbPool<'_>, id: Self::IdType) -> Result<Self, Error>
|
||||||
where diesel::helper_types::Limit<<Self::Table as FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>>::Output>: LoadQuery<'static, DbConn<'conn>, Self> + Send + 'static + Sized
|
where diesel::helper_types::Limit<<Self::Table as FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>>::Output>: LoadQuery<'static, DbConn<'async_trait>, Self> + Send + 'static + Sized
|
||||||
{
|
{
|
||||||
let mut conn = get_conn::<'conn2, 'a>(pool).await?;
|
|
||||||
let col = Self::table().primary_key();
|
let col = Self::table().primary_key();
|
||||||
// FindDsl is not used because it uses a private trait
|
// FindDsl is not used because it uses a private trait
|
||||||
let query = FilterDsl::filter(Self::table(), ExpressionMethods::eq(col, id));
|
let query = FilterDsl::filter(Self::table(), ExpressionMethods::eq(col, id));
|
||||||
let future = RunQueryDsl::first::<'static, 'conn, Self>(query, &mut conn);
|
let mut conn = get_conn(pool).await?;
|
||||||
|
let future = RunQueryDsl::first::<'static, 'async_trait, Self>(query, &mut conn);
|
||||||
future.await
|
future.await
|
||||||
}
|
}
|
||||||
/// when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
|
/// when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
|
||||||
|
|
Loading…
Reference in a new issue