I'm new to AWS and I'm having problems trying to develop a simple Lambda function with Node.js. In DynamoDB, I have a table named Game with 3 attributes: gamepk, user, result.
In just one single execution of the Lambda function, I want to insert a collection of game elements (the number of elements in the collection could vary).
I had been reading some tutorials and it said I should use batchWriteItem, but because the collection of Game elements is variable I don't know how to proceed.
Could somebody write a function in Node.js that solves my problem?
An example of the JSON that the lambda function receives is this one:
{
"games": [{
"gamepk": "1",
"user": "rolo",
"result": "1-0"
},
{
"gamepk": "2",
"user": "jhon",
"result": "1-1"
}
]
}