我尝试使用过滤器表达式在 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/