aws / aws-sdk-ruby-record

Official repository for the aws-record gem, an abstraction for Amazon DynamoDB.
Apache License 2.0
318 stars 41 forks source link

How to query against local or global index? #97

Closed nitesh-varma closed 4 years ago

nitesh-varma commented 5 years ago

Hi,

How to query against local or global index?

Can you please advise, how we can query against created local or global index of table/model?

Thanks

nerixim commented 4 years ago

Hope this helps you @nitesh-varma

# First, define your index aside attributes
global_secondary_index(
  :c_index,
  hash_key: :a,
  range_key: :c,
  projection: {
    projection_type: 'ALL',
  },
)

# then set `index_name` keyword parameter and query as always
query(
  index_name: :c_index,
  ...
)