nickmarotta
4/16/2019 - 6:58 PM

DynamoDb Put

Dynamo db put operation using javascript.

const AWS = require("aws-sdk");

AWS.config.update({
  region: "us-east-1",
  endpoint: "http://dynamodb.us-east-1.amazonaws.com"
});

var docClient = new AWS.DynamoDB.DocumentClient();

var params = {
  TableName: "test-dynamo-table",
  Item: {
    exampleItemField: "test"
  }
};

docClient.put(params, function(err, data) {
  if (err) {
    console.error(
      "Unable to add item. Error JSON:",
      JSON.stringify(err, null, 2)
    );
  } else {
    console.log("Added item:", JSON.stringify(data, null, 2));
  }
});