I've got a question regarding GSI. The question is quite easy for people who are working with DynamoDB :)
Currently, I'm learning about AWS/DynamoDB with creating a blog. So each post got one category. I got one big problem that if I want to get all posts which got a special category. Now I'm using a scan and contains a filter.
EDIT: To create models I'm using 'dynamodb-toolbox'
I heard that I can apply a GSI and get all posts with category by searching with GSI. The biggest problem is... I do not know how can I create GSI, how can I use it in query width DocumentClient and node.js
Thank you for your help!
I do not know how can I create GSI
This is on the documentation, more specifically available here.
I got one big problem that if I want to get all posts which got a special category. Now I'm using a scan and contains a filter.
In this case and based on your data model currently, you need to configure a GSI with category
being the partition key and id
being the sort key, where you need to configure the primary key as being the composite primary key of PK and SK, as described here.
This will allow you to query the data by category on that GSI, as you have the category as the partition key, you will hit one partition when you perform your query.
how can I use it in query width DocumentClient and node.js
I suggest that you figure these out first, and make it work in isolation w/o worrying about your programming language constraints. Once you get a handle of this, you can worry about programming language challenges in isolation.