Reputation: 135
I have dynamoDB table for order processing with following structure.
I have few more properties and I want to filter orders based on the status. For now I used scan method to get orders based on the status. But I would like to implement query statement to achieve more efficiency during query execution for this. How can I implement query statement to filter orders based on the status property ?
Thank you
Upvotes: 0
Views: 127
Reputation: 23848
You need a GSI with STATUS as the partition key...
Then in the query, you tell it to use the GSI.
{
"TableName": "YourTable",
"IndexName": "StatusIndex",
"KeyConditionExpression": "status = :v_status",
"ExpressionAttributeValues": {
":v_status": {"S": "FILLED"}
},
}
Upvotes: 0