mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-09-09 16:08:49 -06:00
Stuff
This commit is contained in:
parent
374b0f6f9e
commit
cab4bc6ab3
@ -12,8 +12,7 @@ use diesel::{
|
|||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
impl SentActivity {
|
||||||
impl Crud for Activity {
|
|
||||||
pub async fn create(pool: &mut DbPool<'_>, form: SentActivityForm) -> Result<Self, Error> {
|
pub async fn create(pool: &mut DbPool<'_>, form: SentActivityForm) -> Result<Self, Error> {
|
||||||
use crate::schema::sent_activity::dsl::sent_activity;
|
use crate::schema::sent_activity::dsl::sent_activity;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -152,12 +152,15 @@ where ca.comment_id = c.id"
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for Comment {
|
impl<'query> Crud<'query> for Comment {
|
||||||
type InsertForm = CommentInsertForm;
|
type InsertForm = CommentInsertForm;
|
||||||
type UpdateForm = CommentUpdateForm;
|
type UpdateForm = CommentUpdateForm;
|
||||||
type IdType = CommentId;
|
type IdType = CommentId;
|
||||||
|
|
||||||
async fn delete(pool: &mut DbPool<'_>, comment_id: CommentId) -> Result<usize, Error> {
|
async fn delete(pool: &mut DbPool<'_>, comment_id: CommentId) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(comment.find(comment_id)).execute(conn).await
|
diesel::delete(comment.find(comment_id)).execute(conn).await
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
|||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for CommentReply {
|
impl<'query> Crud<'query> for CommentReply {
|
||||||
type InsertForm = CommentReplyInsertForm;
|
type InsertForm = CommentReplyInsertForm;
|
||||||
type UpdateForm = CommentReplyUpdateForm;
|
type UpdateForm = CommentReplyUpdateForm;
|
||||||
type IdType = CommentReplyId;
|
type IdType = CommentReplyId;
|
||||||
@ -17,7 +17,10 @@ impl Crud for CommentReply {
|
|||||||
async fn create(
|
async fn create(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
comment_reply_form: &Self::InsertForm,
|
comment_reply_form: &Self::InsertForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
// since the return here isnt utilized, we dont need to do an update
|
// since the return here isnt utilized, we dont need to do an update
|
||||||
|
@ -23,19 +23,25 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
|||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for Community {
|
impl<'query> Crud<'query> for Community {
|
||||||
type InsertForm = CommunityInsertForm;
|
type InsertForm = CommunityInsertForm;
|
||||||
type UpdateForm = CommunityUpdateForm;
|
type UpdateForm = CommunityUpdateForm;
|
||||||
type IdType = CommunityId;
|
type IdType = CommunityId;
|
||||||
|
|
||||||
async fn delete(pool: &mut DbPool<'_>, community_id: CommunityId) -> Result<usize, Error> {
|
async fn delete(pool: &mut DbPool<'_>, community_id: CommunityId) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(community::table.find(community_id))
|
diesel::delete(community::table.find(community_id))
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let is_new_community = match &form.actor_id {
|
let is_new_community = match &form.actor_id {
|
||||||
Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(),
|
Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(),
|
||||||
None => true,
|
None => true,
|
||||||
|
@ -65,18 +65,24 @@ impl LocalUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for LocalUser {
|
impl<'query> Crud<'query> for LocalUser {
|
||||||
type InsertForm = LocalUserInsertForm;
|
type InsertForm = LocalUserInsertForm;
|
||||||
type UpdateForm = LocalUserUpdateForm;
|
type UpdateForm = LocalUserUpdateForm;
|
||||||
type IdType = LocalUserId;
|
type IdType = LocalUserId;
|
||||||
|
|
||||||
async fn delete(pool: &mut DbPool<'_>, local_user_id: LocalUserId) -> Result<usize, Error> {
|
async fn delete(pool: &mut DbPool<'_>, local_user_id: LocalUserId) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(local_user.find(local_user_id))
|
diesel::delete(local_user.find(local_user_id))
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let mut form_with_encrypted_password = form.clone();
|
let mut form_with_encrypted_password = form.clone();
|
||||||
let password_hash =
|
let password_hash =
|
||||||
|
@ -38,12 +38,15 @@ use diesel::{dsl::insert_into, result::Error, QueryDsl};
|
|||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModRemovePost {
|
impl<'query> Crud<'query> for ModRemovePost {
|
||||||
type InsertForm = ModRemovePostForm;
|
type InsertForm = ModRemovePostForm;
|
||||||
type UpdateForm = ModRemovePostForm;
|
type UpdateForm = ModRemovePostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModRemovePostForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModRemovePostForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_remove_post)
|
insert_into(mod_remove_post)
|
||||||
@ -67,12 +70,15 @@ impl Crud for ModRemovePost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModLockPost {
|
impl<'query> Crud<'query> for ModLockPost {
|
||||||
type InsertForm = ModLockPostForm;
|
type InsertForm = ModLockPostForm;
|
||||||
type UpdateForm = ModLockPostForm;
|
type UpdateForm = ModLockPostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModLockPostForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModLockPostForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_lock_post)
|
insert_into(mod_lock_post)
|
||||||
@ -96,12 +102,15 @@ impl Crud for ModLockPost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModFeaturePost {
|
impl<'query> Crud<'query> for ModFeaturePost {
|
||||||
type InsertForm = ModFeaturePostForm;
|
type InsertForm = ModFeaturePostForm;
|
||||||
type UpdateForm = ModFeaturePostForm;
|
type UpdateForm = ModFeaturePostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModFeaturePostForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModFeaturePostForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_feature_post)
|
insert_into(mod_feature_post)
|
||||||
@ -125,12 +134,15 @@ impl Crud for ModFeaturePost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModRemoveComment {
|
impl<'query> Crud<'query> for ModRemoveComment {
|
||||||
type InsertForm = ModRemoveCommentForm;
|
type InsertForm = ModRemoveCommentForm;
|
||||||
type UpdateForm = ModRemoveCommentForm;
|
type UpdateForm = ModRemoveCommentForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommentForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_remove_comment)
|
insert_into(mod_remove_comment)
|
||||||
@ -154,12 +166,15 @@ impl Crud for ModRemoveComment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModRemoveCommunity {
|
impl<'query> Crud<'query> for ModRemoveCommunity {
|
||||||
type InsertForm = ModRemoveCommunityForm;
|
type InsertForm = ModRemoveCommunityForm;
|
||||||
type UpdateForm = ModRemoveCommunityForm;
|
type UpdateForm = ModRemoveCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommunityForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_remove_community)
|
insert_into(mod_remove_community)
|
||||||
@ -183,12 +198,15 @@ impl Crud for ModRemoveCommunity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModBanFromCommunity {
|
impl<'query> Crud<'query> for ModBanFromCommunity {
|
||||||
type InsertForm = ModBanFromCommunityForm;
|
type InsertForm = ModBanFromCommunityForm;
|
||||||
type UpdateForm = ModBanFromCommunityForm;
|
type UpdateForm = ModBanFromCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModBanFromCommunityForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_ban_from_community)
|
insert_into(mod_ban_from_community)
|
||||||
@ -212,12 +230,15 @@ impl Crud for ModBanFromCommunity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModBan {
|
impl<'query> Crud<'query> for ModBan {
|
||||||
type InsertForm = ModBanForm;
|
type InsertForm = ModBanForm;
|
||||||
type UpdateForm = ModBanForm;
|
type UpdateForm = ModBanForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModBanForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModBanForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_ban::dsl::mod_ban;
|
use crate::schema::mod_ban::dsl::mod_ban;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_ban)
|
insert_into(mod_ban)
|
||||||
@ -226,7 +247,10 @@ impl Crud for ModBan {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModBanForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_ban::dsl::mod_ban;
|
use crate::schema::mod_ban::dsl::mod_ban;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(mod_ban.find(from_id))
|
diesel::update(mod_ban.find(from_id))
|
||||||
@ -237,12 +261,15 @@ impl Crud for ModBan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModHideCommunity {
|
impl<'query> Crud<'query> for ModHideCommunity {
|
||||||
type InsertForm = ModHideCommunityForm;
|
type InsertForm = ModHideCommunityForm;
|
||||||
type UpdateForm = ModHideCommunityForm;
|
type UpdateForm = ModHideCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModHideCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModHideCommunityForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_hide_community)
|
insert_into(mod_hide_community)
|
||||||
@ -266,12 +293,15 @@ impl Crud for ModHideCommunity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModAddCommunity {
|
impl<'query> Crud<'query> for ModAddCommunity {
|
||||||
type InsertForm = ModAddCommunityForm;
|
type InsertForm = ModAddCommunityForm;
|
||||||
type UpdateForm = ModAddCommunityForm;
|
type UpdateForm = ModAddCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModAddCommunityForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_add_community::dsl::mod_add_community;
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_add_community)
|
insert_into(mod_add_community)
|
||||||
@ -295,12 +325,15 @@ impl Crud for ModAddCommunity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModTransferCommunity {
|
impl<'query> Crud<'query> for ModTransferCommunity {
|
||||||
type InsertForm = ModTransferCommunityForm;
|
type InsertForm = ModTransferCommunityForm;
|
||||||
type UpdateForm = ModTransferCommunityForm;
|
type UpdateForm = ModTransferCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModTransferCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModTransferCommunityForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_transfer_community)
|
insert_into(mod_transfer_community)
|
||||||
@ -324,12 +357,15 @@ impl Crud for ModTransferCommunity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for ModAdd {
|
impl<'query> Crud<'query> for ModAdd {
|
||||||
type InsertForm = ModAddForm;
|
type InsertForm = ModAddForm;
|
||||||
type UpdateForm = ModAddForm;
|
type UpdateForm = ModAddForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &ModAddForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModAddForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_add::dsl::mod_add;
|
use crate::schema::mod_add::dsl::mod_add;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_add)
|
insert_into(mod_add)
|
||||||
@ -338,7 +374,10 @@ impl Crud for ModAdd {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModAddForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::mod_add::dsl::mod_add;
|
use crate::schema::mod_add::dsl::mod_add;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(mod_add.find(from_id))
|
diesel::update(mod_add.find(from_id))
|
||||||
@ -349,12 +388,15 @@ impl Crud for ModAdd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for AdminPurgePerson {
|
impl<'query> Crud<'query> for AdminPurgePerson {
|
||||||
type InsertForm = AdminPurgePersonForm;
|
type InsertForm = AdminPurgePersonForm;
|
||||||
type UpdateForm = AdminPurgePersonForm;
|
type UpdateForm = AdminPurgePersonForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(admin_purge_person)
|
insert_into(admin_purge_person)
|
||||||
@ -378,12 +420,15 @@ impl Crud for AdminPurgePerson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for AdminPurgeCommunity {
|
impl<'query> Crud<'query> for AdminPurgeCommunity {
|
||||||
type InsertForm = AdminPurgeCommunityForm;
|
type InsertForm = AdminPurgeCommunityForm;
|
||||||
type UpdateForm = AdminPurgeCommunityForm;
|
type UpdateForm = AdminPurgeCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(admin_purge_community)
|
insert_into(admin_purge_community)
|
||||||
@ -407,12 +452,15 @@ impl Crud for AdminPurgeCommunity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for AdminPurgePost {
|
impl<'query> Crud<'query> for AdminPurgePost {
|
||||||
type InsertForm = AdminPurgePostForm;
|
type InsertForm = AdminPurgePostForm;
|
||||||
type UpdateForm = AdminPurgePostForm;
|
type UpdateForm = AdminPurgePostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(admin_purge_post)
|
insert_into(admin_purge_post)
|
||||||
@ -436,12 +484,15 @@ impl Crud for AdminPurgePost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for AdminPurgeComment {
|
impl<'query> Crud<'query> for AdminPurgeComment {
|
||||||
type InsertForm = AdminPurgeCommentForm;
|
type InsertForm = AdminPurgeCommentForm;
|
||||||
type UpdateForm = AdminPurgeCommentForm;
|
type UpdateForm = AdminPurgeCommentForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(admin_purge_comment)
|
insert_into(admin_purge_comment)
|
||||||
|
@ -20,12 +20,15 @@ use diesel_async::RunQueryDsl;
|
|||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for PasswordResetRequest {
|
impl<'query> Crud<'query> for PasswordResetRequest {
|
||||||
type InsertForm = PasswordResetRequestForm;
|
type InsertForm = PasswordResetRequestForm;
|
||||||
type UpdateForm = PasswordResetRequestForm;
|
type UpdateForm = PasswordResetRequestForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &PasswordResetRequestForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &PasswordResetRequestForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(password_reset_request)
|
insert_into(password_reset_request)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
@ -15,18 +15,24 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, JoinOnDsl, Quer
|
|||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for Person {
|
impl<'query> Crud<'query> for Person {
|
||||||
type InsertForm = PersonInsertForm;
|
type InsertForm = PersonInsertForm;
|
||||||
type UpdateForm = PersonUpdateForm;
|
type UpdateForm = PersonUpdateForm;
|
||||||
type IdType = PersonId;
|
type IdType = PersonId;
|
||||||
|
|
||||||
async fn delete(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<usize, Error> {
|
async fn delete(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(person::table.find(person_id))
|
diesel::delete(person::table.find(person_id))
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(person::table)
|
insert_into(person::table)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
@ -9,7 +9,7 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
|||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for PersonMention {
|
impl<'query> Crud<'query> for PersonMention {
|
||||||
type InsertForm = PersonMentionInsertForm;
|
type InsertForm = PersonMentionInsertForm;
|
||||||
type UpdateForm = PersonMentionUpdateForm;
|
type UpdateForm = PersonMentionUpdateForm;
|
||||||
type IdType = PersonMentionId;
|
type IdType = PersonMentionId;
|
||||||
|
@ -34,17 +34,23 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextE
|
|||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for Post {
|
impl<'query> Crud<'query> for Post {
|
||||||
type InsertForm = PostInsertForm;
|
type InsertForm = PostInsertForm;
|
||||||
type UpdateForm = PostUpdateForm;
|
type UpdateForm = PostUpdateForm;
|
||||||
type IdType = PostId;
|
type IdType = PostId;
|
||||||
|
|
||||||
async fn delete(pool: &mut DbPool<'_>, post_id: PostId) -> Result<usize, Error> {
|
async fn delete(pool: &mut DbPool<'_>, post_id: PostId) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(post.find(post_id)).execute(conn).await
|
diesel::delete(post.find(post_id)).execute(conn).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(post)
|
insert_into(post)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
@ -11,12 +11,15 @@ use lemmy_utils::error::LemmyError;
|
|||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for PrivateMessage {
|
impl<'query> Crud<'query> for PrivateMessage {
|
||||||
type InsertForm = PrivateMessageInsertForm;
|
type InsertForm = PrivateMessageInsertForm;
|
||||||
type UpdateForm = PrivateMessageUpdateForm;
|
type UpdateForm = PrivateMessageUpdateForm;
|
||||||
type IdType = PrivateMessageId;
|
type IdType = PrivateMessageId;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(private_message)
|
insert_into(private_message)
|
||||||
.values(form)
|
.values(form)
|
||||||
@ -38,7 +41,10 @@ impl Crud for PrivateMessage {
|
|||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
async fn delete(pool: &mut DbPool<'_>, pm_id: Self::IdType) -> Result<usize, Error> {
|
async fn delete(pool: &mut DbPool<'_>, pm_id: Self::IdType) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(private_message.find(pm_id))
|
diesel::delete(private_message.find(pm_id))
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
|
@ -13,12 +13,15 @@ use diesel::{insert_into, result::Error, ExpressionMethods, QueryDsl};
|
|||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for RegistrationApplication {
|
impl<'query> Crud<'query> for RegistrationApplication {
|
||||||
type InsertForm = RegistrationApplicationInsertForm;
|
type InsertForm = RegistrationApplicationInsertForm;
|
||||||
type UpdateForm = RegistrationApplicationUpdateForm;
|
type UpdateForm = RegistrationApplicationUpdateForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(registration_application)
|
insert_into(registration_application)
|
||||||
.values(form)
|
.values(form)
|
||||||
@ -38,7 +41,10 @@ impl Crud for RegistrationApplication {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete(pool: &mut DbPool<'_>, id_: Self::IdType) -> Result<usize, Error> {
|
async fn delete(pool: &mut DbPool<'_>, id_: Self::IdType) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(registration_application.find(id_))
|
diesel::delete(registration_application.find(id_))
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
|
@ -13,12 +13,12 @@ use diesel_async::RunQueryDsl;
|
|||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Crud for Site {
|
impl<'query> Crud<'query> for Site {
|
||||||
type InsertForm = SiteInsertForm;
|
type InsertForm = SiteInsertForm;
|
||||||
type UpdateForm = SiteUpdateForm;
|
type UpdateForm = SiteUpdateForm;
|
||||||
type IdType = SiteId;
|
type IdType = SiteId;
|
||||||
|
|
||||||
/// Use SiteView::read_local, or Site::read_from_apub_id instead
|
/*/// Use SiteView::read_local, or Site::read_from_apub_id instead
|
||||||
async fn read<'conn, 'pool: 'conn>(
|
async fn read<'conn, 'pool: 'conn>(
|
||||||
_pool: &'pool mut DbPool<'_>,
|
_pool: &'pool mut DbPool<'_>,
|
||||||
_site_id: SiteId,
|
_site_id: SiteId,
|
||||||
@ -35,9 +35,12 @@ impl Crud for Site {
|
|||||||
'async_trait: 'conn,
|
'async_trait: 'conn,
|
||||||
{
|
{
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}*/
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let is_new_site = match &form.actor_id {
|
let is_new_site = match &form.actor_id {
|
||||||
Some(id_) => Site::read_from_apub_id(pool, id_).await?.is_none(),
|
Some(id_) => Site::read_from_apub_id(pool, id_).await?.is_none(),
|
||||||
None => true,
|
None => true,
|
||||||
@ -73,7 +76,10 @@ impl Crud for Site {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete(pool: &mut DbPool<'_>, site_id: SiteId) -> Result<usize, Error> {
|
async fn delete(pool: &mut DbPool<'_>, site_id: SiteId) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(site.find(site_id)).execute(conn).await
|
diesel::delete(site.find(site_id)).execute(conn).await
|
||||||
}
|
}
|
||||||
|
@ -4,56 +4,50 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use diesel::{
|
use diesel::{
|
||||||
associations::HasTable,
|
associations::HasTable,
|
||||||
backend::Backend,
|
|
||||||
deserialize::{FromSqlRow, Queryable},
|
|
||||||
dsl,
|
dsl,
|
||||||
dsl::insert_into,
|
expression::{AsExpression, TypedExpressionType},
|
||||||
expression::{
|
|
||||||
is_aggregate,
|
|
||||||
is_contained_in_group_by,
|
|
||||||
AsExpression,
|
|
||||||
IsContainedInGroupBy,
|
|
||||||
ValidGrouping,
|
|
||||||
},
|
|
||||||
expression_methods::ExpressionMethods,
|
expression_methods::ExpressionMethods,
|
||||||
pg::Pg,
|
query_dsl::methods::{FilterDsl, LimitDsl},
|
||||||
query_builder::{AsQuery, IntoUpdateTarget, Only, Query, QueryFragment, QueryId},
|
|
||||||
query_dsl::methods::{FilterDsl, LimitDsl, SelectDsl},
|
|
||||||
query_source::{AppearsInFromClause, Once},
|
|
||||||
result::Error,
|
result::Error,
|
||||||
sql_types::{is_nullable::NotNull, SqlType},
|
sql_types::SqlType,
|
||||||
AsChangeset,
|
AsChangeset,
|
||||||
Column,
|
|
||||||
Expression,
|
Expression,
|
||||||
Identifiable,
|
|
||||||
Insertable,
|
Insertable,
|
||||||
QuerySource,
|
|
||||||
SelectableExpression,
|
|
||||||
Table,
|
Table,
|
||||||
};
|
};
|
||||||
use diesel_async::{methods::LoadQuery, AsyncConnection, RunQueryDsl};
|
use diesel_async::{methods::LoadQuery, AsyncPgConnection, RunQueryDsl};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
#[async_trait]
|
/*Self: Send + 'static + Sized + HasTable,
|
||||||
pub trait Crud
|
|
||||||
where
|
|
||||||
Self: Send + 'static + Sized + HasTable,
|
|
||||||
Self::Table:
|
Self::Table:
|
||||||
FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>> + Send + Sized + 'static,
|
FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>> + Send + Sized + 'static,
|
||||||
<Self::Table as FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>>::Output:
|
<Self::Table as FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>>::Output:
|
||||||
LimitDsl + Send + Sized + 'static,
|
LimitDsl + Send + Sized + 'static,
|
||||||
<<Self::Table as Table>::PrimaryKey as Expression>::SqlType: SqlType,
|
<<Self::Table as Table>::PrimaryKey as Expression>::SqlType: SqlType,
|
||||||
<Self::Table as Table>::PrimaryKey: ExpressionMethods + Send + Sized + 'static,
|
<Self::Table as Table>::PrimaryKey: ExpressionMethods + Send + Sized + 'static,*/
|
||||||
|
#[async_trait]
|
||||||
|
pub trait Crud<'query>
|
||||||
|
where
|
||||||
|
Self: HasTable + Sized,
|
||||||
|
Self::Table: FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>,
|
||||||
|
dsl::Filter<Self::Table, dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>:
|
||||||
|
LimitDsl + Send,
|
||||||
|
for<'query2> dsl::Limit<dsl::Filter<Self::Table, dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>>:
|
||||||
|
Send + LoadQuery<'query2, AsyncPgConnection, Self> + 'query2,
|
||||||
|
<<Self as HasTable>::Table as Table>::PrimaryKey: ExpressionMethods + Send,
|
||||||
|
<<<Self as HasTable>::Table as Table>::PrimaryKey as Expression>::SqlType:
|
||||||
|
SqlType + TypedExpressionType,
|
||||||
{
|
{
|
||||||
type InsertForm;
|
type InsertForm;
|
||||||
type UpdateForm;
|
type UpdateForm;
|
||||||
type IdType: Hash
|
type IdType: Hash
|
||||||
+ Eq
|
+ Eq
|
||||||
+ Send
|
|
||||||
+ 'static
|
|
||||||
+ Sized
|
+ Sized
|
||||||
|
+ Send
|
||||||
+ 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>
|
||||||
|
where
|
||||||
|
'query: 'async_trait;
|
||||||
/*{
|
/*{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(Self::table())
|
insert_into(Self::table())
|
||||||
@ -61,22 +55,13 @@ where
|
|||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}*/
|
}*/
|
||||||
async fn read<'conn, 'pool: 'conn>(
|
async fn read(pool: &mut DbPool<'_>, id: Self::IdType) -> Result<Self, Error> {
|
||||||
pool: &'pool mut DbPool<'_>,
|
let mut conn = get_conn(pool).await?;
|
||||||
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<'pool>, Self> + Send + 'static + Sized,
|
|
||||||
Self: 'conn,
|
|
||||||
{
|
|
||||||
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 mut conn = get_conn(pool).await?;
|
let conn_ref = &mut *conn;
|
||||||
let conn_ref = &mut conn;
|
let future = RunQueryDsl::first::<Self>(query, conn_ref);
|
||||||
let future = RunQueryDsl::first::<'_, '_, Self>(query, conn_ref);
|
|
||||||
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.
|
||||||
@ -84,7 +69,9 @@ where
|
|||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
id: Self::IdType,
|
id: Self::IdType,
|
||||||
form: &Self::UpdateForm,
|
form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error>;
|
) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait;
|
||||||
/*{
|
/*{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(Self::table().find(id))
|
diesel::update(Self::table().find(id))
|
||||||
@ -92,7 +79,10 @@ where
|
|||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}*/
|
}*/
|
||||||
async fn delete(pool: &mut DbPool<'_>, id: Self::IdType) -> Result<usize, Error> {
|
async fn delete(_pool: &mut DbPool<'_>, _id: Self::IdType) -> Result<usize, Error>
|
||||||
|
where
|
||||||
|
'query: 'async_trait,
|
||||||
|
{
|
||||||
Err(Error::NotFound)
|
Err(Error::NotFound)
|
||||||
/*let conn = &mut get_conn(pool).await?;
|
/*let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(Self::table().find(id)).execute(conn).await*/
|
diesel::delete(Self::table().find(id)).execute(conn).await*/
|
||||||
|
Loading…
Reference in New Issue
Block a user