Skip to content

Instantly share code, notes, and snippets.

@robzhu
Created May 2, 2019 18:16
Show Gist options
  • Save robzhu/39b74b9b1d61931a5219a608d6e340d7 to your computer and use it in GitHub Desktop.
Save robzhu/39b74b9b1d61931a5219a608d6e340d7 to your computer and use it in GitHub Desktop.
async function deleteFriendByValue(friendName) {
const Key = { id: "1234" };
// fetch the document
let result = await DynamoDB.get({
TableName,
Key
}).promise();
// Delete the value from the set. This operation is idempotent and will not produce an error if the value(s) are missing.
const { err, data } = await updateWithErrorWrapper({
TableName,
Key,
UpdateExpression: `DELETE friends :valuesToRemove`,
ExpressionAttributeValues: {
":valuesToRemove": DynamoDB.createSet([friendName])
}
});
if (err) {
console.error("unhandled error: " + err);
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment