Jarrett GXZ
Jarrett GXZ

Reputation: 608

AWS DynamoDB filter expression to filter by a particular field in an object within a list

Suppose I have the following database schema for each item:


{
 config: [
   {
    value1: "value_1"
    value2: "value_2"
   }
 ]
}

For each item in the database, there is a field config with each of the item in its list being an object. Are there any AWS DynamoDB query methods or filter expressions to filter an item by matching the value1 field in the config list? Thank you everyone for your help!

Upvotes: 2

Views: 1200

Answers (1)

Greg0ry
Greg0ry

Reputation: 1069

aws dynamodb scan help is your friend, try this:

aws dynamodb scan \
    --table-name=your-table-name \
    --projection-expression="#config.value1,whateverelse" \
    --expression-attribute-names='{"#config":"config"}' \
    --expression-attribute-values='{":v1":{"N": "1"}}' \
    --filter-expression="#config.value1 > :v1"

If any part of path is reserved keyword then it needs to be included in --expression-attribute-names like in example above.

Upvotes: 2

Related Questions