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
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With