javascript - 在哈希键上使用键条件 'GE' 查询 dynamoDB

标签 javascript node.js amazon-web-services nosql amazon-dynamodb

我正在尝试使用这样的关键条件在 dynamoDB 表上运行查询

KeyConditions: {
  userID: {
    ComparisonOperator: 'GE',
    AttributeValueList: [{N: '0'}]
  }
}

当我使用 ComparisonOperator 作为“EQ”运行此查询时,没有出现任何问题。但是,当它是“GE”时,我收到一条错误消息,指出不支持查询键条件。

注意userID是一个hash key

最佳答案

来自Dynamo DB Query Documentation :

A Query operation directly accesses items from a table using the table primary key, or from an index using the index key. You must provide a specific hash key value. You can narrow the scope of the query by using comparison operators on the range key value, or on the index key. You can use the ScanIndexForward parameter to get results in forward or reverse order, by range key or by index key.

您必须提供哈希键才能查询 Dynamo DB。您可以通过 Scan 操作或多个 Query 操作来完成您尝试做的事情,但是除了 equals 中的哈希键之外,没有其他方法可以指定条件DynamoDB。

关于javascript - 在哈希键上使用键条件 'GE' 查询 dynamoDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22696538/

相关文章:

javascript - 在 MEAN CRUD 应用程序中确认删除后无法读取未定义的属性 '_id'?

javascript - 使用 PassportJS 进行 token 认证/授权

node.js - Cloud9 安装问题

javascript - 如何使用 typescript 处理 json 对象

amazon-web-services - 是什么阻止了我的 S3 存储桶被终止?

arrays - 循环遍历多个图像的数组以单独上传到AWS s3 ReactJS

javascript - Node.js 不从浏览器执行 DB 函数

javascript - 查找数组中存在的下一个 DOM 对象

javascript - 根据浏览器宽度更改链接文本

amazon-web-services - 如何在 AWS Lambda 函数中获取经过 Cognito 身份验证的用户信息?