dynamoid icon indicating copy to clipboard operation
dynamoid copied to clipboard

filter expression with or?

Open rhuang opened this issue 2 years ago • 2 comments

I want to query against an index but also apply a filter expression with contains and or. Is this supported in Dynamoid? I don't think I can find any examples within the code.

This is what I want to do:

query_params = {
  table_name: 'table_name',
  index_name: 'some-index,
  select: 'ALL_ATTRIBUTES',
  expression_attribute_values: {
    ':name_search1' => 'johnny',
    ':name_search2' => 'jane',
    ':user_id' => '1234567890'
  },
  key_condition_expression: 'user_id = :user_id',
  filter_expression: 'contains(name_search, :name_search1) or contains(name_search, :name_search2)',
  scan_index_forward: false
}

results = Aws::DynamoDB::Client.new(region: 'us-east-1').query(query_params)

rhuang avatar Apr 05 '23 19:04 rhuang

Dynamoid still uses deprecated QueryFilter and KeyConditions attributes for Query operation and doesn't support more flexible FilterExpression and KeyConditionExpression yet.

It's planned to release it in the next minor versions.

andrykonchin avatar Apr 05 '23 20:04 andrykonchin

Thank you for the quick response. Will watch for the next few releases.

rhuang avatar Apr 05 '23 21:04 rhuang