【问题标题】:DynamoDB - ScanIndexForward(true/false) return the same [closed]DynamoDB - ScanIndexForward(true/false)返回相同的[关闭]
【发布时间】:2020-10-08 01:30:31
【问题描述】:

我使用了 ScanIndexForward: false 并没有得到预期的结果。所以,我从 false 变成了 true,它返回的结果和 false 一样。

【问题讨论】:

  • 您的索引是由散列和范围键组成的吗? (如果是,dynamodb 将根据范围键排序)
  • 这只是一个哈希键。我需要添加范围键,对吗?
  • 是的,正确。您需要使用哈希键和范围键重新创建索引,dynamodb 将根据范围键排序

标签: node.js amazon-web-services amazon-dynamodb


【解决方案1】:

创建表并添加主键时,应为主键添加排序键。或者,如果您使用索引,则索引应该有一个排序键。 ScanIndexForward 将按排序键对记录进行排序。

Query results are always sorted by the sort key value. If the data type of the sort key is Number, the results are returned in numeric order; otherwise, the results are returned in order of UTF-8 bytes. By default, the sort order is ascending. To reverse the order, set the ScanIndexForward parameter to false.

您可以在 AWS documentation 中找到更多详细信息

【讨论】:

    猜你喜欢
    • 2012-02-27
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-29
    • 2015-10-03
    相关资源
    最近更新 更多