Created
May 2, 2019 18:16
-
-
Save robzhu/39b74b9b1d61931a5219a608d6e340d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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