Sean Moss
Sean Moss

Reputation: 43

Scan DynamoDB and filter for items with empty array value

I'm trying to find all entries in a table with an attribute (non-index) "IDs" for arrays that are empty using the DynamoDB online interface.

The array generally contain strings and if I scan the table with a filter of "ID" String Contains "value" it will return all the entries that contain that value in the array. However I'm trying to find all the arrays that contain no values.

I've tried using the Not Contains filter, but that doesn't seem to work as I need to find arrays that don't contain anything not just one particular value.

An example of an entry I'm trying to find:

{
  "accountname": "test_account",
  "username": "test_user",
  "IDs": []
}

and an example of an entry I would be trying to exclude:


    {
      "accountname": "test_account",
      "username": "test_user",
      "IDs": ["test_id1"]
    }

Upvotes: 0

Views: 4450

Answers (1)

AbhinavD
AbhinavD

Reputation: 7282

I have my array stored as list and querying agains NULL works for me.

Here is how the data is stored

dynamodb data

and here is how fetching it works

query dynamodb with empty array

Upvotes: 1

Related Questions