Skip to content

Commit

Permalink
chore: update readme example (#272)
Browse files Browse the repository at this point in the history
Add a note that the V2-list client might be removed before GA. It's recommended to use client + command to make request.
  • Loading branch information
AllanZhengYP authored Jun 4, 2019
1 parent 379a5c1 commit 636e601
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,23 @@ Let’s walk through setting up a project that depends on DynamoDB from the SDK
2. Inside of the project, run: `npm install --save @aws-sdk/client-dynamodb-v2-node@preview`
3. Create a new file called index.js, create a DynamoDB service client and send a request.
```javascript
const {DynamoDB} = require('@aws-sdk/client-dynamodb-v2-node');
const {DynamoDBClient} = require('@aws-sdk/client-dynamodb-node/DynamoDBClient');
const {ListTablesCommand} = require('@aws-sdk/client-dynamodb-node/commands/ListTablesCommand');
async function example() {
const client = new DynamoDBClient({region: 'us-west-2'});
const command = new ListTablesCommand({});
try {
const results = await client.send(command);
console.log(results.TableNames.join('\n'));
} catch (err) {
console.error(err);
}
}
example();
```
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:
```javascript
const {DynamoDB} = require('@aws-sdk/client-dynamodb-node');
async function example() {
const client = new DynamoDB({region: 'us-west-2'});
try {
Expand All @@ -32,6 +48,7 @@ async function example() {
}
example();
```
Note that this client is subject to change. It might be removed with SDK V3 comes closer to production-ready.

## New features
### Modularized packages
Expand Down

0 comments on commit 636e601

Please sign in to comment.