Home > database >  AWS DynamoDB delete Item using lambda nodejs
AWS DynamoDB delete Item using lambda nodejs

Time:12-31

I am trying to delete some entries from DynamoDB table, but I keep getting the error: ValidationException: The provided key element does not match the schema

Screen shot of the entry I want to delete, partition key is identifier:

I have tried the following code:

I am using dynamodb = AWS.DynamoDB.DocumentClient

what am I doing wrong???

CodePudding user response:

If you want to delete an item, you have to specify the entire primary key. In the case of a table with a composite key, that means both partition and sort keys are required.

From documentation for DeleteItem - Key attribute:

For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.

  • Related