Skip to content

Instantly share code, notes, and snippets.

@radzionc
Created February 26, 2018 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radzionc/ba371a44a92c91f77159b20361d101bc to your computer and use it in GitHub Desktop.
Save radzionc/ba371a44a92c91f77159b20361d101bc to your computer and use it in GitHub Desktop.
const aws = require('aws-sdk')
module.exports = [
async () => {...},
async () => {...},
async () => {...},
async () => {
const documentClient = new aws.DynamoDB.DocumentClient()
const projects = await documentClient
.scan({
TableName: 'Projects',
ProjectionExpression: 'id',
FilterExpression: 'attribute_not_exists(creationTime)'
})
.promise()
.then(({ Items }) => Items)
return Promise.all(
projects.map(({ id }) =>
documentClient
.update({
TableName: 'Projects',
Key: { id },
UpdateExpression: 'set creationTime = :creationTime',
ExpressionAttributeValues: {
':creationTime': Date.now()
}
})
.promise()
)
)
},
async () => {...},
async () => {...},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment