0
0
DynamoDBquery~10 mins

Document client abstraction 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 create a DynamoDB DocumentClient instance.

DynamoDB
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.[1]();
Drag options to blanks, or click blank then click option'
ADocumentClient
BClient
CService
DDocument
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Client' instead of 'DocumentClient' causes errors because 'Client' is not a valid class.
Using 'Service' or 'Document' alone are not valid constructors.
2fill in blank
medium

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

DynamoDB
const params = {
  TableName: 'Users',
  Item: { id: '123', name: 'Alice' }
};
docClient.[1](params).promise();
Drag options to blanks, or click blank then click option'
Aquery
Bput
Cget
Dscan
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'put' will only retrieve data, not insert.
Using 'query' or 'scan' are for reading multiple items, not inserting.
3fill in blank
hard

Fix the error in the code to get an item by key using DocumentClient.

DynamoDB
const params = {
  TableName: 'Products',
  Key: { productId: 'abc123' }
};
docClient.[1](params).promise();
Drag options to blanks, or click blank then click option'
Aput
Bdelete
Cupdate
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'put' or 'update' will overwrite or modify data instead of reading.
Using 'delete' removes the item, not retrieves it.
4fill in blank
hard

Fill both blanks to update an item attribute using DocumentClient.

DynamoDB
const params = {
  TableName: 'Orders',
  Key: { orderId: '789' },
  UpdateExpression: 'set [1] = :val',
  ExpressionAttributeValues: { ':val': [2] }
};
docClient.update(params).promise();
Drag options to blanks, or click blank then click option'
Astatus
B'shipped'
C'delivered'
Dquantity
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the value without quotes causes syntax errors.
Using a wrong attribute name will update the wrong field.
5fill in blank
hard

Fill all three blanks to query items with a condition using DocumentClient.

DynamoDB
const params = {
  TableName: 'Employees',
  KeyConditionExpression: '[1] = :id',
  ExpressionAttributeNames: { '#name': '[2]' },
  ExpressionAttributeValues: { ':id': [3] }
};
docClient.query(params).promise();
Drag options to blanks, or click blank then click option'
AemployeeId
Bname
C'E123'
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Using attribute names without quotes in ExpressionAttributeValues causes errors.
Mixing up attribute names and values leads to wrong queries.