Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Latest commit

 

History

History
36 lines (28 loc) · 854 Bytes

20-delete-an-item-from-a-dynamo-db-table-with-delete-operation.md

File metadata and controls

36 lines (28 loc) · 854 Bytes

Delete an item from a DynamoDB table with delete operation

📹 Video

Let's delete a todo!

const deleteTodoItem = async (data: { id: string }) => {
    const { id } = data;

    if (id && id !== "") {
        await dynamo
            .delete({
                TableName: tableName,
                Key: {
                    // each todo needs a unique id
                    id
                }
            })
            .promise();
    }

    return id;
};

Let's test this by sending a DELETE request:

{
    "id": "this_is_a_new_id"
}

We should get a response like this: "Todo item with an id of this_is_a_new_id deleted from the database".

👍 Validate that the todo item was indeed deleted with a new GET request.