Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const keys = Object.keys(item)
- let updateExpression = ""
- if (keys[0] === "ttl") {
- updateExpression = "SET #TTL = :" + String.fromCharCode(97 + 0)
- } else {
- updateExpression = "SET " + keys[0] + " = :" + String.fromCharCode(97 + 0)
- }
- for (let i = 1; i < keys.length; i++) {
- if (keys[i] === "ttl") {
- updateExpression = updateExpression + ", #TTL = :" + String.fromCharCode(97 + i)
- } else {
- updateExpression = updateExpression + ", " + keys[i] + " = :" + String.fromCharCode(97 + i)
- }
- }
- const expressionAttributeValuesDict = {}
- for (let i = 0; i < keys.length; i++) {
- expressionAttributeValuesDict[(":" + String.fromCharCode(97 + i))] = item[keys[i]]
- }
- const params = {
- TableName: getDynamoDBTableName(url),
- Key: {
- 'Device_Browser_Version': {
- S: getDeviceBrowserVersionKey(device, browser, version),
- },
- 'URL': {
- S: url,
- },
- },
- UpdateExpression: updateExpression,
- ExpressionAttributeValues: expressionAttributeValuesDict,
- ReturnValues: "ALL_NEW",
- }
Add Comment
Please, Sign In to add comment