node.js - GSI 中使用 FilterExpression 的 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
推荐阅读
- ios - How to select tab bar item without selecting it
- sql - oracle sql查询 - 根据优先级填充值
- linux - 如何为此创建 bash 脚本
- python - isometric tile selection formula is slightly off
- bash - append unique id file then scp in bash
- java - 如何通过 Java 直接调用 WebSockets?(是“带有 Application.cfm 的 WebSockets 吗?”)
- c# - 有没有办法让文件流下载到 Blazor 中的浏览器?
- python - 在 django 页面上渲染 pandas 数据框
- python - Kivy Spinner 添加了一个未编码的小部件
- apache-spark - 为 Delta Lake 中的表创建索引