Skip to content

Instantly share code, notes, and snippets.

@radzionc
Created February 26, 2018 10:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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