Introduction
GetItem lets you quickly find one specific item in a DynamoDB table using its unique key.
Jump into concepts and practice - no test required
GetItem lets you quickly find one specific item in a DynamoDB table using its unique key.
GetItem {
TableName: "TableName",
Key: {
"PrimaryKeyName": { "S": "PrimaryKeyValue" }
}
}The Key must include the primary key attributes exactly as defined in your table.
Use S for string type, N for number type, and B for binary type values.
GetItem {
TableName: "Users",
Key: {
"UserID": { "S": "user123" }
}
}GetItem {
TableName: "Orders",
Key: {
"OrderID": { "N": "101" }
}
}This query fetches the product with ID 'P1001' from the 'Products' table.
GetItem {
TableName: "Products",
Key: {
"ProductID": { "S": "P1001" }
}
}If the item does not exist, the response will not include an Item field.
GetItem is fast because it uses the primary key directly, no scanning needed.
GetItem fetches one item by its primary key from a DynamoDB table.
It is efficient and quick for retrieving single records.
Always provide the exact key attributes in the request.
GetItem operation in DynamoDB do?GetItem in AWS SDK for JavaScript v3?TableName and the key attribute is Key (singular), not Keys.getItem, and the object must include TableName and Key with the primary key value.GetItem call return if the item exists?client.getItem({ TableName: 'Products', Key: { ProductId: 'P100' } })client.getItem({ TableName: 'Orders', Key: { orderId: 'O123' } })DepartmentId (partition key) and EmployeeId (sort key). Which GetItem call is correct?DepartmentId (partition key) and EmployeeId (sort key) as named properties in the Key object. Providing only one key or incorrect syntax like non-named values will fail.