Reputation: 41
I've been trying to delete an item from a DynamoDB table, with no success and no actual errors. My delete function is as follows:
public async deleteToken(token: string) {
const input: DeleteItemCommandInput = {
TableName: this.tableName,
Key: {
Token: {
S: token,
},
},
};
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/classes/deleteitemcommand.html
const command = new DeleteItemCommand(input);
//Send command to DDB
const response = await this.client.send(command);
console.log("response", response);
return response;
}
Although in postman I'm getting a success code, nothing actually happens. The item is still in the table. I have checked and the token value I'm using in the input is the correct one. The weird this is that the response promise never resolves and I'm not getting an error. The console log below "const response = await this.client.send(command);" is ignored.
Any ideas please?
Upvotes: 4
Views: 1347
Reputation: 1558
Is this Token
field acting as a secondary index (GSI) in your Dynamo table? As far as I know you only can apply a delete operation using a primary one, so if Token
is a GSI, I would say the easiest way is to do it in two steps:
Token
).Upvotes: 0