Dynamoid/dynamoid

filter expression with or?

rhuang opened this issue · 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)

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.

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