Reputation: 39
I have this lambda function.
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({region : 'eu-west-1'});
var dynamodb = new AWS.DynamoDB();
var datetime = new Date().getTime().toString();
exports.handler = function(event, context) {
dynamodb.updatetItem({
"TableName": "tablename",
"Item" : {
"messageHash": {"S": hash },
"date": {"S": String(datetime) }
},
"ReturnValues": "ALL_OLD"
}, function(err, data) {
Any idea why every call ending with error "TypeError: dynamodb.updatetItem is not a function" ?? I think everything is right ... :-/
Upvotes: 1
Views: 2076
Reputation: 11
// Create a new instance of DynamoDB DocumentClient
var dynamodb = new AWS.DynamoDB.DocumentClient();
The DocumentClient simplifies working with AWS DynamoDB by handling data conversion automatically. If you're facing issues with DynamoDB operations, ensure that you have installed and configured the AWS SDK properly:
const AWS = require("aws-sdk");
AWS.config.update({ region: "us-east-1" });
var dynamodb = new AWS.DynamoDB.DocumentClient();
If you still get an error, check if your AWS credentials are set correctly. Let me know if you need more help!
Upvotes: 0
Reputation: 2814
I had to use: dynamodb.update()
Excerpts from AWS documentation:
update(params, callback) ⇒ AWS.Request Edits an existing item's attributes, or adds a new item to the table if it does not already exist by delegating to AWS.DynamoDB.updateItem().
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html
Upvotes: 4
Reputation: 9401
You have a typo in your code.
dynamodb.updatetItem -> dynamodb.updateItem
Upvotes: 1