When calling the DynamoDB deleteItem API, I am getting The provided key element does not match the schema
error. After researching, I have found that this error occurs when you don't give the full primary key, (i.e the table has a range key but the API call does not specify it). However, in my case, the table has no range key, it has got only a hash key called pk
.
Here is my code:
const dynamodbDocClient = new AWS.DynamoDB.DocumentClient({ logger: console });
socket.on('my-event', async (payload) => {
await dynamodbDocClient.delete({
TableName: 'MyTable',
Key: { pk: payload.id },
}).promise()
})
Can someone list all other cases where this error may occur?