Add delete/patch todos
This commit is contained in:
		@@ -167,7 +167,7 @@ pub async fn update_todo(
 | 
			
		||||
        "
 | 
			
		||||
        UPDATE todos
 | 
			
		||||
        SET value = ?
 | 
			
		||||
        WHERE guild_id = ?
 | 
			
		||||
        WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)
 | 
			
		||||
            AND id = ?
 | 
			
		||||
        ",
 | 
			
		||||
        todo.value,
 | 
			
		||||
@@ -181,6 +181,11 @@ pub async fn update_todo(
 | 
			
		||||
        json!({"errors": vec!["Unknown error"]})
 | 
			
		||||
    })?;
 | 
			
		||||
 | 
			
		||||
    if let Err(e) = transaction.commit().await {
 | 
			
		||||
        warn!("Couldn't commit transaction: {:?}", e);
 | 
			
		||||
        return json_err!("Couldn't commit transaction.");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Ok(json!({}))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -197,7 +202,7 @@ pub async fn delete_todo(
 | 
			
		||||
    sqlx::query!(
 | 
			
		||||
        "
 | 
			
		||||
        DELETE FROM todos
 | 
			
		||||
        WHERE guild_id = ?
 | 
			
		||||
        WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)
 | 
			
		||||
            AND id = ?
 | 
			
		||||
        ",
 | 
			
		||||
        guild_id,
 | 
			
		||||
@@ -210,5 +215,10 @@ pub async fn delete_todo(
 | 
			
		||||
        json!({"errors": vec!["Unknown error"]})
 | 
			
		||||
    })?;
 | 
			
		||||
 | 
			
		||||
    if let Err(e) = transaction.commit().await {
 | 
			
		||||
        warn!("Couldn't commit transaction: {:?}", e);
 | 
			
		||||
        return json_err!("Couldn't commit transaction.");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Ok(json!({}))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user