File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -398,4 +398,17 @@ impl Database {
398398 )
399399 } )
400400 }
401+
402+ pub fn delete_account ( & self , maybe_user_id : Option < i32 > ) -> Result < ( ) , String > {
403+ let user_id = self . resolve_user_id_protected ( maybe_user_id) ?;
404+
405+ let mut conn = self . pool . get ( ) . unwrap ( ) ;
406+ conn. transaction ( |conn| -> QueryResult < ( ) > {
407+ diesel:: delete ( users:: table)
408+ . filter ( users:: user_id. eq ( user_id) )
409+ . execute ( conn) ?;
410+ Ok ( ( ) )
411+ } )
412+ . map_err ( |reason| format ! ( "Delete user {} failed. Reason: {}" , user_id, reason) )
413+ }
401414}
Original file line number Diff line number Diff line change @@ -75,6 +75,13 @@ impl Mutation {
7575 }
7676 }
7777
78+ fn delete_account ( context : & Database , user_id : Option < i32 > ) -> FieldResult < bool > {
79+ dbtry ! {
80+ context. delete_account( user_id)
81+ } ?;
82+ Ok ( true )
83+ }
84+
7885 // Product types
7986 fn add_user_product_type (
8087 context : & Database ,
You can’t perform that action at this time.
0 commit comments