Search code examples
amazon-dynamodb

DynamoDbClient.BatchGetItem with only partition key


Given a table like:

ForumPosts
postId                      commentId
========================================
POST::100                   COMMENT:1
POST::100                   COMMENT:2
POST::100                   COMMENT:3
POST::100                   COMMENT:4
POST::100                   COMMENT:5
POST::101                   COMMENT:1
POST::101                   COMMENT:2
POST::101                   COMMENT:3
POST::101                   COMMENT:4
POST::101                   COMMENT:5

Is it possible to perform a batchGet on just postId=100 that returns the 5 items, or I can only do that with Query?


Solution

  • You want to use a Query. Batch get requires knowing the full primary key for each item. If there’s a reason you’re thinking you’d rather do a batch get, please elaborate.