所以我想扫描表并通过存储在2个字段中的值的总和来过滤结果 .
目前我的js代码看起来像这样
var params = {
TableName : "core-atv-quota-table-dev",
FilterExpression: "#info.#branch = :branchId AND {{#info.#points / #info.#location}} > :score",
ExpressionAttributeNames:{
"#info": "matching_info",
"#branch": "branch",
"#points": "points",
"#location": "location"
},
ExpressionAttributeValues: {
":branchId": "3",
":score": "8"
},
ReturnConsumedCapacity: 'TOTAL'
};
docClient.scan(params, function(err, data) {
if (err) console.error(err); // an error occurred
else console.log(data); // successful response
});
如您所见, {{#points/#location}}
无效 . 在这种特殊情况下,我可以计算并存储插入值并与之进行比较但在我的用例中我不知道 matching_info
中的哪些字段将用于过滤结果 .
我正在寻找一种方法来让dynamodb从项目中获取值,处理它们(加法,减法等)并使用处理后的信息来匹配给过滤器的值 .
1 回答
不幸的是,这是不可能的 .
FilterExpression
不允许进行算术运算 .FilterExpression Docs
Comparison Operator and Function Reference