Skip to content

Instantly share code, notes, and snippets.

@robzhu
Created May 2, 2019 18:27
Show Gist options
  • Save robzhu/c641c7ee2b304589469f3165e4f554c0 to your computer and use it in GitHub Desktop.
Save robzhu/c641c7ee2b304589469f3165e4f554c0 to your computer and use it in GitHub Desktop.
async function deleteFriendByValue(friendName: string) {
const Key = { id: "1234" };
// 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