0
0
DynamoDBquery~10 mins

Why SDK integration is essential in DynamoDB - Test Your Understanding

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

Complete the code to initialize the DynamoDB client using the AWS SDK.

DynamoDB
const AWS = require('aws-sdk');
const dynamoDB = new AWS.DynamoDB({ region: [1] });
Drag options to blanks, or click blank then click option'
A'database'
B'nodejs'
C'sdk'
D'us-west-2'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-region string like 'nodejs' or 'sdk' instead of a valid AWS region.
2fill in blank
medium

Complete the code to put an item into a DynamoDB table using the SDK.

DynamoDB
const params = {
  TableName: 'Users',
  Item: {
    'UserId': { S: '123' },
    'Name': { S: [1] }
  }
};
dynamoDB.putItem(params, (err, data) => { /* callback */ });
Drag options to blanks, or click blank then click option'
A'Alice'
B123
Cnull
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number or boolean instead of a string for the 'Name' attribute.
3fill in blank
hard

Fix the error in the code to correctly get an item from DynamoDB using the SDK.

DynamoDB
const params = {
  TableName: 'Users',
  Key: {
    'UserId': { [1]: '123' }
  }
};
dynamoDB.getItem(params, (err, data) => { /* callback */ });
Drag options to blanks, or click blank then click option'
AN
BS
CBOOL
DNULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'N' for a string key causes errors.
4fill in blank
hard

Fill both blanks to update an item attribute using the DynamoDB SDK.

DynamoDB
const params = {
  TableName: 'Users',
  Key: { 'UserId': { [1]: '123' } },
  UpdateExpression: 'set #N = :name',
  ExpressionAttributeNames: { '#N': [2] },
  ExpressionAttributeValues: { ':name': { S: 'Bob' } }
};
dynamoDB.updateItem(params, (err, data) => { /* callback */ });
Drag options to blanks, or click blank then click option'
AS
B'Name'
CN
D'Age'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'N' for UserId key or wrong attribute name in ExpressionAttributeNames.
5fill in blank
hard

Fill all three blanks to query items from DynamoDB with a condition using the SDK.

DynamoDB
const params = {
  TableName: 'Orders',
  KeyConditionExpression: '#id = :orderId',
  ExpressionAttributeNames: { [1]: 'OrderId' },
  ExpressionAttributeValues: { [2]: { S: 'A123' } },
  ProjectionExpression: [3]
};
dynamoDB.query(params, (err, data) => { /* callback */ });
Drag options to blanks, or click blank then click option'
A'#orderId'
B':orderId'
C'OrderId, Amount'
D'#id'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up keys and values in ExpressionAttributeNames and ExpressionAttributeValues.
Using wrong attribute names in ProjectionExpression.