Skip to content

Commit 4a33342

Browse files
authored
docs(upgrading): add doc client and endpoint discovery (#2212)
* docs(upgrading): add doc client and endpoint discovery * docs(upgrading): add PutCommand import in lib-dynamodb
1 parent 0e83313 commit 4a33342

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

Diff for: UPGRADING.md

+34-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ might not have the same name either.
4444
- [`endpointDiscoveryEnabled`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#endpointDiscoveryEnabled-property)
4545
- **v2**: Whether to call operations with endpoints given by service dynamically.
4646
- **v3**: Not available. Planned. This option configures endpoint discovery behavior, which is not yet available in v3.
47+
Currently `TimeStreamQuery` and `TimeStreamWrite` client cannot fetch endpoints dynamically because they rely on
48+
this behavior. [#2211](https://github.com/aws/aws-sdk-js-v3/issues/2211) is tracking this issue.
4749
- [`hostPrefixEnabled`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#hostPrefixEnabled-property)
4850
- **v2**: Whether to marshal request parameters to the prefix of hostname.
4951
- **v3**: **Deprecated**. SDK _always_ injects the hostname prefix when necessary.
@@ -195,8 +197,37 @@ In v3, [`@aws-sdk/s3-request-presigner` package](https://github.com/aws/aws-sdk-
195197
is available. You don't have to differentiate `getSignedUrl()` and `getSignedUrlPromise()` any more. We also have [a blog](https://aws.amazon.com/blogs/developer/generate-presigned-url-modular-aws-sdk-javascript/)
196198
discussing the details of this package.
197199

198-
<!---
199200
## DynamoDB Document Client
200201

201-
TBD
202-
-->
202+
In v2, you can use the [`AWS.DynamoDB.DocumentClient` class](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html)
203+
to call DynamoDB API with native JavaScript types like Buffer, Array, and Object. It thus simplifies working with items
204+
in Amazon DynamoDB by abstracting away the notion of attribute values.
205+
206+
In v3, equivalent [`@aws-sdk/lib-dynamodb`](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_lib_dynamodb.html)
207+
is available. It's similar to normal service clients from v3 SDK, with the difference that it takes a basic DynamoDB
208+
client in its constructor. Here's an brief example:
209+
210+
```javascript
211+
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; // ES6 import
212+
// const { DynamoDBClient } = require("@aws-sdk/client-dynamodb"); // CommonJS import
213+
import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb"; // ES6 import
214+
// const { DynamoDBDocumentClient, PutCommand } = require("@aws-sdk/lib-dynamodb"); // CommonJS import
215+
216+
// Bare-bones DynamoDB Client
217+
const client = new DynamoDBClient({});
218+
219+
// Bare-bones document client
220+
const ddbDocClient = DynamoDBDocumentClient.from(client); // client is DynamoDB client
221+
222+
await ddbDocClient.send(
223+
new PutCommand({
224+
TableName,
225+
Item: {
226+
id: "1",
227+
content: "content from DynamoDBDocumentClient",
228+
},
229+
})
230+
);
231+
```
232+
233+
More examples and configurations are available in the [package README](https://github.com/aws/aws-sdk-js-v3/blob/main/lib/lib-dynamodb/README.md).

0 commit comments

Comments
 (0)