Created
February 26, 2018 10:58
-
-
Save radzionc/ba371a44a92c91f77159b20361d101bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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