現在、範囲値は によって取得される BigDecimalTime.now.to_f
であり、次のようにユーザーのすべてのドキュメントを取得したいと考えています。
table = dynamo_db.tables['some_table']
table.load_schema
docs = table.items.where(:user_id => user_id).select.map {|i| i.attributes}
はdocs
範囲値の降順で並べられます。
現在、範囲値は によって取得される BigDecimalTime.now.to_f
であり、次のようにユーザーのすべてのドキュメントを取得したいと考えています。
table = dynamo_db.tables['some_table']
table.load_schema
docs = table.items.where(:user_id => user_id).select.map {|i| i.attributes}
はdocs
範囲値の降順で並べられます。
SDK ソースコードを掘り下げた後、メソッド AWS::DynamoDB::ItemCollection#query のこの小さな便利なナゲットを見つけることができました
# @option [Boolean] :scan_index_forward (true) Specifies which
# order records will be returned. Defaults to returning them
# in ascending range key order. Pass false to reverse this.
myuser_id
はハッシュ値であるため、クエリを次のように修正できました。
docs = table.items.query(:hash_value => user_id, :scan_index_forward => false).select.map {|i| i.attributes}