Your way of explanation was awesome. I have seen many videos related to SQS and Lambda but you have explained everything step by step very clearly. Thank you very much. I have a doubt while connecting to DynamoDB you have given the apiVersion from where can you get that? If you give me replay it's a great help for me.
Hi Prasanthi, Thanks for you comments. Love it. There are two ways you can deal with DynamoDB tables. One way is using "new AWS.DynamoDB()" and other way is "new AWS.DynamoDB.DocumentClient();" The "DocumentClient" is wrapper for "AWS.DynamoDB()". The "DocumentClient" is working as more natural way. To your question regarding "apiVersion", you don't necessarily provide the `apiVersion`. Honestly I can't remember where is the apiVersion is mentioned. BTW you can still use DocumentClient without specifying the apiVersion. Furthermore I have put some code to understand the different. Hope this helps // using "DynamoDB client": var params = { Item: { "AlbumTitle": { S: "AAAA }, "Artist": { S: "John" }, "SongTitle": { S: "Cheap Trills" } }, TableName: "Music" }; dynamodb.putItem(params, function (err, data) { if (err) console.log(err) else console.log(data); }); // Using "DocumentClient" var params = { Item: { "AlbumTitle": "AAAAA", "Artist": "John", "SongTitle": "Cheap Trills" }, TableName: "Music" }; var documentClient = new AWS.DynamoDB.DocumentClient(); documentClient.put(params, function (err, data) { if (err) console.log(err); else console.log(data); });
Thanks for the video but i'm getting this error in cloudwatch logs, not sure what did i miss, do i need to make any changes in demo-event? 2024-01-24T16:23:32.852+05:30 Copy 2024-01-24T10:53:32.852Z 07d6413e-053e-5a45-9983-1f14eb593d03 ERROR Error in executing lambda: SyntaxError: Unexpected token ( in JSON at position 0 at JSON.parse () at Runtime.exports.handler (/var/task/index.js:18:25) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29) 2024-01-24T10:53:32.852Z 07d6413e-053e-5a45-9983-1f14eb593d03 ERROR Error in executing lambda: SyntaxError: Unexpected token ( in JSON at position 0 at JSON.parse () at Runtime.exports.handler (/var/task/index.js:18:25) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)