I have a DynamoDB table like this:
I want to list all posts irrespective of users, i-e by getting all data whose sort key is "post". How can I achieve this?
I have heard about Global Secondary Index, but couldn't figure out how to use them.
CodePudding user response:
You create a global secondary index with a Key Schema like this:
- Partition Key: SK attribute of the base table
- Sort Key: PK attribute of the base table
It's called an inverted index. Then you can Query
the Global Secondary Index by specifying the IndexName
in the Query and search for all items that have "post"
as the value for SK
.