0
0
DynamoDBquery~10 mins

AWS SDK for JavaScript/Node.js in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the DynamoDB client from AWS SDK.

DynamoDB
const { DynamoDBClient } = require('[1]');
Drag options to blanks, or click blank then click option'
A@aws-sdk/client-dynamodb
Baws-sdk
Caws-sdk-client
Daws-sdk-v3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'aws-sdk' which is v2 and not modular.
Using incorrect package names like 'aws-sdk-client'.
2fill in blank
medium

Complete the code to create a new DynamoDB client with region 'us-east-1'.

DynamoDB
const client = new DynamoDBClient({ region: '[1]' });
Drag options to blanks, or click blank then click option'
Aus-west-2
Beu-central-1
Cus-east-1
Dap-southeast-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a region that does not match the intended deployment.
Leaving the region undefined.
3fill in blank
hard

Fix the error in the code to put an item into DynamoDB using the client.

DynamoDB
const params = { TableName: 'Users', Item: { id: { S: '123' }, name: { S: 'Alice' } } };
await client.[1](new PutItemCommand(params));
Drag options to blanks, or click blank then click option'
Aput
Bsend
CputItemCommand
DputItem
Attempts:
3 left
💡 Hint
Common Mistakes
Calling 'putItem' directly on the client.
Using incorrect method names like 'put'.
4fill in blank
hard

Fill both blanks to import and create a PutItemCommand for DynamoDB.

DynamoDB
const { [1] } = require('@aws-sdk/client-dynamodb');
const command = new [2]({ TableName: 'Users', Item: { id: { S: '001' } } });
Drag options to blanks, or click blank then click option'
APutItemCommand
BDynamoDBClient
CPutCommand
DGetItemCommand
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing PutItemCommand with PutCommand or GetItemCommand.
Importing the client instead of the command.
5fill in blank
hard

Fill all three blanks to get an item from DynamoDB and extract the attribute 'name'.

DynamoDB
const { [1] } = require('@aws-sdk/client-dynamodb');
const client = new DynamoDBClient({ region: 'us-east-1' });
const command = new [2]({ TableName: 'Users', Key: { id: { S: '123' } } });
const response = await client.[3](command);
const userName = response.Item?.name?.S;
Drag options to blanks, or click blank then click option'
AGetItemCommand
BPutItemCommand
Csend
DgetItem
Attempts:
3 left
💡 Hint
Common Mistakes
Using PutItemCommand instead of GetItemCommand.
Calling 'getItem' method directly on the client.