Foundations · Lesson 2 of 20
The key is the address
GetItem needs the whole primary key: partition and sort.
Why
This table has a composite key: a partition key (pk, the room) and a sort key (sk, the message). The partition key decides which partition an item lives on; the sort key orders items within that partition.
GetItem fetches exactly one item, and it needs the whole key. Knowing only the room is not enough to GetItem a message. That is a job for Query, next.
Know the full key, pay for one item. GetItem is the cheapest read DynamoDB offers.
Chatdynoxide · wasm · DynamoDB API 2012-08-10 · contract 1
Try an example
The full key: the room (partition) and the message id (sort). One item, the cheapest read there is.
pk(pk)
sk(sk)
topic
from
text
Run an operation to see the raw engine response.
table Chatkeys pk / skitems 22