Ruby on Rails dynamo db IN statement

Viewed 147

How to make IN query with dynamo db

i have tried to do this, but it doens't work if i pass array page_ids

resp = client.scan({
  expression_attribute_names: {
    '#id' => 'id'
  },
  expression_attribute_values: {
    ":id" => page_ids                      
  },
  filter_expression: '#id IN(:id)',
  table_name: table_name,
})

how to fix it?

1 Answers

I recommend plugging in the dynamoid gem to get an ORM on top of your DDB models. When you do, the following is an example of an in query for DynamoDB using the dynamoid gem.

MyModel.where("my_value.in": [1, 2, 3]).batch(25).each do |record|
  p record
end
Related