shubhamgoyal

Untitled

Apr 30th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const keys = Object.keys(item)
  2.     let updateExpression = ""
  3.     if (keys[0] ===  "ttl") {
  4.       updateExpression = "SET #TTL = :" + String.fromCharCode(97 + 0)
  5.     } else {
  6.       updateExpression = "SET " + keys[0] + " = :" + String.fromCharCode(97 + 0)
  7.     }
  8.     for (let i = 1; i < keys.length; i++) {
  9.       if (keys[i] ===  "ttl") {
  10.         updateExpression = updateExpression + ", #TTL = :" + String.fromCharCode(97 + i)
  11.       } else {
  12.         updateExpression = updateExpression + ", " + keys[i] + " = :" + String.fromCharCode(97 + i)
  13.       }
  14.     }
  15.     const expressionAttributeValuesDict = {}
  16.     for (let i = 0; i < keys.length; i++) {
  17.       expressionAttributeValuesDict[(":" + String.fromCharCode(97 + i))] = item[keys[i]]
  18.     }
  19.     const params = {
  20.       TableName: getDynamoDBTableName(url),
  21.       Key: {
  22.         'Device_Browser_Version': {
  23.           S: getDeviceBrowserVersionKey(device, browser, version),
  24.         },
  25.         'URL': {
  26.           S: url,
  27.         },
  28.       },
  29.       UpdateExpression: updateExpression,
  30.       ExpressionAttributeValues: expressionAttributeValuesDict,
  31.       ReturnValues: "ALL_NEW",
  32.     }
Add Comment
Please, Sign In to add comment