node.js - 使用 FilterExpression 在 GSI 中进行 DynamoDB 查询

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

我尝试使用过滤器表达式在 GSI 中执行查询,但 AWS 一直告诉我找不到表达式。 查询如下:

var tableQuery = {
        TableName: "posts",
        KeyConditionExpression: "#wy = :wkYr",
        FilterExpression: "#ac = :isAct",
        IndexName: "weekYear-date-index",
        ScanIndexForward: false,
        Limit: 50,
        ExpressionAttributeNames: {
            "#wy": "weekYear",
            "#ac": "isActive"
        },
        ExpressionAttributeValues: {
            ":wkYr": cWeekYear,
            ":isAct": {BOOL: true}
        }
    };

以及显示的错误:

An expression attribute value used in expression is not defined; attribute value: :isAct

我一直在尝试不同的方法,但似乎没有任何效果,有什么想法吗?

当前查询的控制台日志:

 {
  "TableName": "posts",
  "KeyConditionExpression": "#wy = :wkYr",
  "FilterExpression": "#ac = :isAct",
  "IndexName": "weekYear-date-index",
  "ScanIndexForward": false,
  "Limit": 50,
  "ExpressionAttributeNames": {
    "#wy": "weekYear",
    "#ac": "isActive"
  },
  "ExpressionAttributeValues": {
    ":wkYr": 2040,
    ":isAct": {
      "BOOL": true
    }
  }
}

最佳答案

这就是你应该传递你的值的方式 ":isAct": true

关于node.js - 使用 FilterExpression 在 GSI 中进行 DynamoDB 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50611479/

相关文章:

node.js setEncoding 问题

mysql - 无法连接到 AWS RDS 上的 mysql(错误 2003)

amazon-dynamodb - dynamodb cloudformation模板错误

java - @DynamoDBIndexHashKey 必须指定 HASH GSI 名称之一

python - DynamoDB - 如何查询嵌套属性 boto3

javascript - 文件数量计数不正确

javascript - 使用 javascript 绘制从客户端套接字发送的图像

node.js - 缺少必需参数 : redirect_uri with passport-google-oauth

javascript - 在 Red Hat Enterprise Linux 7.1 的远程 AWS 实例上安装 NODEJS

python - Fargate 任务的资源 ARN 以允许连接到 Elasticsearch