2

According to the docs I should get a data structure with the item as it was prior to the deletion (in case there was no error)
I do check there was no error but I get an empty object for data:

    docClient.delete(params, (err, data) => {
    if (err) {
        console.error('Error tring to delete item:' + err);
        callback(err, null); // error
    } else if (!data.Items || data.Items.length == 0) {
        console.info(JSON.stringify(data));
        callback(null, null); // no items
    } else  {
        console.info(JSON.stringify(data));
        callback(null, data.Items[0].ExposeStartTimestamp);
    }
});

Both prints empty json: {}

1 Answer 1

12

In order for the deleted data to appear in the response, the request should contain the attribute ReturnValues with value ALL_OLD.

var params = {
    TableName: 'TableName',
    Key: {
        HouseId: houseId
    },
    ReturnValues: 'ALL_OLD'
};
Sign up to request clarification or add additional context in comments.

3 Comments

I'd hate to think what would happen if they showed that in the example...
That comment made me laugh :-)
Sagilow - have you face any issue like after deleting item in response it return null - In my case it is returning null randomly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.