Skip to content

Commit 636e601

Browse files
authored
chore: update readme example (#272)
Add a note that the V2-list client might be removed before GA. It's recommended to use client + command to make request.
1 parent 379a5c1 commit 636e601

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Diff for: README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,23 @@ Let’s walk through setting up a project that depends on DynamoDB from the SDK
2020
2. Inside of the project, run: `npm install --save @aws-sdk/client-dynamodb-v2-node@preview`
2121
3. Create a new file called index.js, create a DynamoDB service client and send a request.
2222
```javascript
23-
const {DynamoDB} = require('@aws-sdk/client-dynamodb-v2-node');
23+
const {DynamoDBClient} = require('@aws-sdk/client-dynamodb-node/DynamoDBClient');
24+
const {ListTablesCommand} = require('@aws-sdk/client-dynamodb-node/commands/ListTablesCommand');
25+
async function example() {
26+
const client = new DynamoDBClient({region: 'us-west-2'});
27+
const command = new ListTablesCommand({});
28+
try {
29+
const results = await client.send(command);
30+
console.log(results.TableNames.join('\n'));
31+
} catch (err) {
32+
console.error(err);
33+
}
34+
}
35+
example();
36+
```
37+
For users want to use V2-like interfaces, you can import client with only the service name(e.g DynamoDB), and call the operation name directly from the client:
38+
```javascript
39+
const {DynamoDB} = require('@aws-sdk/client-dynamodb-node');
2440
async function example() {
2541
const client = new DynamoDB({region: 'us-west-2'});
2642
try {
@@ -32,6 +48,7 @@ async function example() {
3248
}
3349
example();
3450
```
51+
Note that this client is subject to change. It might be removed with SDK V3 comes closer to production-ready.
3552

3653
## New features
3754
### Modularized packages

0 commit comments

Comments
 (0)