here is the image of data in dynamodb
i want to delete the element from the favRest and i will have to give the value only and it sould do that here is my lambda function
var AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient({ region: 'us-east-1' });
exports.handler = (event, context, callback) => {
const params = {
TableName : 'User',
Key:{
"id": event.user_id,
},
UpdateExpression: "DELETE favRest :p",
ExpressionAttributeValues: {
':p': event.place_id
},
ReturnValues: "ALL_NEW"
}
// TODO: Implementation...
docClient.update(params, (err, data) => {
if (err) {
console.log("Unable to update item. Error: " + err.message);
callback(err);
} else {
console.log("UpdateItem succeeded.");
callback(null, data);
}
});
};
However, it's giving me the following error:
"{\n \"message\": \"Invalid UpdateExpression: Incorrect operand type for operator or function; operator: DELETE, operand type: STRING\",\n \"code\": \"ValidationException\",\n \"time\": \"2018-04-29T18:49:58.628Z\",\n \"requestId\": \"7TDRI4TOF9S71OUJDEKMIOA40RVV4KQNSO5AEMVJF66Q9ASUAAJG\",\n \"statusCode\": 400,\n \"retryable\": false,\n \"retryDelay\": 35.34160854636804\n}"
what should i have to do