Skip to content

Instantly share code, notes, and snippets.

View crsepulv's full-sized avatar

Cristian Sepulveda crsepulv

View GitHub Profile
@crsepulv
crsepulv / getDynamoExpression.js
Created January 22, 2022 04:40
Update Nested Object on DynamoDB using Javascript/Typescript node.js
/**
* Recursive function to get UpdateExpression,ExpressionAttributeValues & ExpressionAttributeNames to update a nested object on dynamoDB
* All levels of the nested object must exist previously on dynamoDB, this only update the value, does not create the branch.
* Only works with objects of objects, not tested with Arrays.
* @param obj , the object to update.
* @param k , the seed is any value, takes sense on the last iteration.
*/
function getDynamoExpression(obj, k) {
const key = Object.keys(obj);