Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ...
- const getModule = (config) => {
- const documentClient = new AWS.DynamoDB.DocumentClient(config)
- return ({
- // ...
- flatUpdateParams: params => ({
- UpdateExpression: `set ${Object.entries(params)
- .map(([key]) => `#${key} = :${key}, `)
- .reduce((acc, str) => acc + str)
- .slice(0, -2)}`,
- ExpressionAttributeNames: Object.keys(params).reduce(
- (acc, key) => ({
- ...acc,
- [`#${key}`]: key
- }),
- {}
- ),
- ExpressionAttributeValues: Object.entries(params).reduce(
- (acc, [key, value]) => ({
- ...acc,
- [`:${key}`]: value
- }),
- {}
- )
- })
- })
- }
- // ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement