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 { utils } = require('dynamo-data-transform'); | |
const TABLE_NAME = 'UsersExample'; | |
/** | |
* The tool supply following parameters: | |
* @param {DynamoDBDocumentClient} ddb - dynamo db document client https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb | |
* @param {boolean} isDryRun - true if this is a dry run | |
*/ | |
const transformUp = async ({ ddb, isDryRun }) => { | |
const addFirstAndLastName = (item) => { | |
// Just for the example: | |
// Assume the FullName has one space between first and last name | |
const [firstName, ...lastName] = item.name.split(' '); | |
return { | |
...item, | |
firstName, | |
lastName: lastName.join(' '), | |
}; | |
}; | |
return utils.transformItems(ddb, TABLE_NAME, addFirstAndLastName, isDryRun); | |
}; | |
module.exports = { | |
transformUp, | |
transformationNumber: 1, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment