Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS.DynamoDB.DocumentClient is not providing data on put

I am using the AWS.DynamoDB.DocumentClient, with Dynamodb local (port 8080). When I perform a put, the data variable in the callback is an empty object. Have I missed something?

import * as AWS from "aws-sdk";


AWS.config.update({
  region: "us-west-2",
  endpoint: "http://localhost:8080"
});


const docClient: any = new AWS.DynamoDB.DocumentClient();


const item = {
      someField:    "456",
      other:         "123"
};

const params = {
  TableName: "TableName",
  Item: item
};

docClient.put(params, function(err, data) {
  if (err) console.log(err);
  else console.log(data); // this produces: {}
});

There is no error, and the item is being inserted\updated - however the data variable is an empty object. Shouldn't this contain values?

Thanks

like image 356
Daryn Avatar asked Jul 20 '16 15:07

Daryn


People also ask

Which is the method of DynamoDB document client is used for returning one or more items and item attributes by accessing every item in a table?

putItem() . Directly access items from a table by primary key or a secondary index. Returns one or more items and item attributes by accessing every item in a table or a secondary index.

What is the difference between scan and query in DynamoDB?

DynamoDB supports two different types of read operations, which are query and scan. A query is a lookup based on either the primary key or an index key. A scan is, as the name indicates, a read call that scans the entire table in order to find a particular result.


1 Answers

You aren't asking for any values to come back, so why do you expect there to be any values coming back? You'll need to set the appropriate parameters ReturnConsumedCapacity and/or ReturnItemCollectionMetrics and/or ReturnValues if you are wanting any of that to come back in the response.

like image 64
Mark B Avatar answered Oct 01 '22 06:10

Mark B