Given a DynamoDB table Users with primary key UserID, what will be the output of this GetItem operation?
{
TableName: "Users",
Key: { "UserID": { "S": "123" } }
}Assume the item with UserID "123" exists and has attributes Name: "Alice" and Age: 30.
const params = {
TableName: "Users",
Key: { "UserID": { "S": "123" } }
};
// Assume dynamodbClient.getItem(params) returns the itemRemember DynamoDB returns attribute values with their types.
DynamoDB GetItem returns the item attributes wrapped with their data types, such as S for string and N for number, inside the Item key.
Which of the following DynamoDB GetItem request objects is syntactically correct?
Check how DynamoDB expects attribute values to be typed.
DynamoDB requires attribute values in the Key to be objects with type keys like S for string and the value as a string. Option A follows this format correctly.
You want to get only the Name attribute from a DynamoDB item with UserID "789". Which GetItem request achieves this efficiently?
Use the recommended way to specify attributes to return in GetItem.
ProjectionExpression is the preferred and efficient way to specify which attributes to return in a GetItem request. AttributesToGet is deprecated.
Consider this GetItem request:
{
TableName: "Orders",
Key: { "OrderID": { "N": 1001 } }
}The item with OrderID 1001 exists, but the response returns Item: null. Why?
Check how DynamoDB expects number attribute values in requests.
DynamoDB requires number attribute values to be strings representing the number, not raw numbers. Passing {"N": 1001} is invalid and causes no match.
If you call DynamoDB's GetItem with a key that does not exist in the table, what will the response contain?
Think about how DynamoDB signals no matching item found.
When no item matches the key, DynamoDB returns a response with Item set to null, not an error.