Skip to content
This repository was archived by the owner on Oct 25, 2021. It is now read-only.

Commit 0d696e3

Browse files
andrewglevyerichendrickson
authored andcommitted
change docClient.putItem() to docClient.put() (mkdecisiondev#18)
1 parent 7d86cfa commit 0d696e3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

aws/lambda-with-other-services/s3-lambda-dynamodb/s3-lambda-dynamodb.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,18 @@ const params = {
102102
These parameters will write entries containing an id and the url of the picture. After `params`, write the code below:
103103

104104
```javascript
105-
let writeToDb = docClient.putItem(params).promise();
105+
let writeToDb = docClient.put(params).promise();
106106
writeToDb.then(function (data) {
107107
callback(null, data);
108108
}).catch(function (err) {
109109
callback(err, null);
110110
});
111111
```
112112

113-
This code creates a promise for S3's `putItem()` function. It then runs that promise, and in the `then()` block (successful case) calls the handler callback inputting data and in the `catch()` block (unsuccessful case) calls the handler callback inputting the error. At MK Decision we use promisified AWS SDK functions as much as possible, but a different way (the way the [AWS SDK documentation](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#putItem-property) uses) would be something like this:
113+
This code creates a promise for S3's `put()` function. It then runs that promise, and in the `then()` block (successful case) calls the handler callback inputting data and in the `catch()` block (unsuccessful case) calls the handler callback inputting the error. At MK Decision we use promisified AWS SDK functions as much as possible, but a different way (the way the [AWS SDK documentation](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#putItem-property) uses) would be something like this:
114114

115115
```javascript
116-
docClient.putItem(params, function (err, data) {
116+
docClient.put(params, function (err, data) {
117117
if (err) {
118118
callback(err, null);
119119
} else {
@@ -151,7 +151,7 @@ module.exports.handler = function(event, context, callback) {
151151
}
152152

153153

154-
let writeToDb = docClient.putItem(params).promise();
154+
let writeToDb = docClient.put(params).promise();
155155
writeToDb.then(function (data) {
156156
callback(null, data);
157157
}).catch(function (err) {

0 commit comments

Comments
 (0)