Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const updateTTLForItem = (partitionKey, sortKey) => {
- const expirationDate = new Date()
- expirationDate.setHours(expirationDate.getHours() + 7 * 24)
- const ttlEpochTime = Math.round(expirationDate.getTime() / 1000)
- const params = {
- ExpressionAttributeNames: {
- "#TTL": "ttl",
- },
- ExpressionAttributeValues: {
- ":ttl": {
- N: ttlEpochTime.toString(),
- },
- },
- Key: {
- "Device_Browser": {
- S: partitionKey,
- },
- "URL": {
- S: sortKey,
- },
- },
- ReturnValues: "ALL_NEW",
- TableName: "dex-v6-items-new",
- UpdateExpression: "SET #TTL = :ttl",
- }
- dynamodb.updateItem(
- params,
- (err, data) => {
- if (err) {
- console.log(err, err.stack)
- } else {
- console.log(data)
- }
- }
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement