带类级别扫描的AWS DynamoDB扫描操作有效,但不支持文档编写器扫描 [英] AWS DynamoDB Scan Operation Works w/ Class Level Scan, but not Document Writer Scan
问题描述
以下参数使用dynamoDB.scan(params, function);
const dynamoDB = new AWS::DynamoDB();
let params = {
TableName: ACCOUNT_USAGE_TABLE,
ExpressionAttributeValues: {
":start_date": {
S: new Date(event.start_date).toISOString(),
},
":end_date": {
S: new Date(event.end_date).toISOString()
}
},
ExpressionAttributeNames: {
"#usage_date": "date",
},
FilterExpression: "#usage_date BETWEEN :start_date AND :end_date",
ExclusiveStartKey: event.LastEvaluatedKey
};
但是将dynamoDB.documentClient.scan(params, function)
与
ValidationException: Invalid FilterExpression: Incorrect operand type for operator or function; operator or function: BETWEEN, operand type: M
关于为什么的任何想法?
Any ideas as to why?
推荐答案
当然,答案直接盯着我. 万一其他人碰到它而没有立即看到它.
Of course, the answer was staring me directly in the face. In case anybody else runs into it and doesn't see it immediately.
JavaScript中的DynamoDB文档客户端使用javascript类型,因此看到start_date
和end_date
对象([object]
)又称为operand type: M
.
The DynamoDB Document Client in javascript uses javascript types and therefore saw the start_date
and end_date
objects ([object]
) a.k.a operand type: M
.
我要做的就是将ExpressionAttributeValues
更改为
ExpressionAttributeValues: {
":start_date": new Date(event.start_date).toISOString(),
":end_date": new Date(event.end_date).toISOString()
},
voilà,它有效.
这篇关于带类级别扫描的AWS DynamoDB扫描操作有效,但不支持文档编写器扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!