目前,我的范围值是 BigDecimal 获得的Time.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
是按范围值降序排列的。
目前,我的范围值是 BigDecimal 获得的Time.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}