Mister_L
Mister_L

Reputation: 2611

dynamodb - scan items by value inside array

I'm doing a table scan. This table has an array as one of its fields, the "apps" field (apps is not a key of any kind). I want to select all rows, whose apps array contains a certain value "MyApp". I tried something of that kind, but my syntax is incorrect:

    ComparisonOperator = "#apps CONTAINS :v",
    ExpressionAttributeNames = {
        '#apps': 'apps'
    },
    ExpressionAttributeValues = {
        ":v": "MyApp"
    }

Thanks.

Upvotes: 7

Views: 14457

Answers (1)

Matias Cicero
Matias Cicero

Reputation: 26331

The documentation about Condition Expressions clearly states that the appropiate syntax is:

contains(#apps, :v)

The correct request would be:

FilterExpression: "contains(#apps, :v)",
ExpressionAttributeNames: { "#apps": "apps" },
ExpressionAttributeValues: { ":v": "MyApp" }

Upvotes: 16

Related Questions