mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 19:31:33 +00:00
Attempt default Crud::create
This commit is contained in:
parent
183c61b3d2
commit
3b3540cb27
1 changed files with 10 additions and 8 deletions
|
@ -29,14 +29,18 @@ LimitDsl + Send + Sized + 'static,
|
||||||
pub trait Crud
|
pub trait Crud
|
||||||
where
|
where
|
||||||
Self: HasTable + Sized,
|
Self: HasTable + Sized,
|
||||||
Self::Table: FindDsl<Self::IdType>,
|
Self::Table: FindDsl<Self::IdType> + 'static,
|
||||||
dsl::Find<Self::Table, Self::IdType>: LimitDsl + Send,
|
dsl::Find<Self::Table, Self::IdType>: LimitDsl + Send,
|
||||||
for<'query> dsl::Limit<dsl::Find<Self::Table, Self::IdType>>:
|
for<'a> dsl::Limit<dsl::Find<Self::Table, Self::IdType>>:
|
||||||
Send + LoadQuery<'query, AsyncPgConnection, Self> + 'query,
|
Send + LoadQuery<'a, AsyncPgConnection, Self> + 'a,
|
||||||
<<Self as HasTable>::Table as Table>::PrimaryKey: ExpressionMethods + Send,
|
<<Self as HasTable>::Table as Table>::PrimaryKey: ExpressionMethods + Send,
|
||||||
<<<Self as HasTable>::Table as Table>::PrimaryKey as Expression>::SqlType:
|
<<<Self as HasTable>::Table as Table>::PrimaryKey as Expression>::SqlType:
|
||||||
SqlType + TypedExpressionType,
|
SqlType + TypedExpressionType,
|
||||||
{
|
{
|
||||||
|
/*for<'a> &'a Self::InsertForm: Insertable<Self::Table>,
|
||||||
|
for<'a> InsertStatement<Self::Table, <&'a Self::InsertForm as Insertable<Self::Table>>::Values>:
|
||||||
|
LoadQuery<'a, AsyncPgConnection, Self> + 'a,
|
||||||
|
for<'a> <&'a Self::InsertForm as Insertable<Self::Table>>::Values: 'a,*/
|
||||||
type InsertForm;
|
type InsertForm;
|
||||||
type UpdateForm;
|
type UpdateForm;
|
||||||
type IdType: Hash
|
type IdType: Hash
|
||||||
|
@ -46,11 +50,9 @@ where
|
||||||
+ AsExpression<<<Self::Table as Table>::PrimaryKey as Expression>::SqlType>;
|
+ AsExpression<<<Self::Table as Table>::PrimaryKey as Expression>::SqlType>;
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>;
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>;
|
||||||
/*{
|
/*{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let query = insert_into(Self::table()).values(form);
|
||||||
insert_into(Self::table())
|
let conn = &mut *get_conn(pool).await?;
|
||||||
.values(form)
|
query.get_result::<Self>(conn).await
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}*/
|
}*/
|
||||||
async fn read(pool: &mut DbPool<'_>, id: Self::IdType) -> Result<Self, Error> {
|
async fn read(pool: &mut DbPool<'_>, id: Self::IdType) -> Result<Self, Error> {
|
||||||
let query = Self::table().find(id);
|
let query = Self::table().find(id);
|
||||||
|
|
Loading…
Reference in a new issue