带类级别扫描的AWS DynamoDB扫描操作有效,但不支持文档编写器扫描 [英] AWS DynamoDB Scan Operation Works w/ Class Level Scan, but not Document Writer Scan

查看:172
本文介绍了带类级别扫描的AWS DynamoDB扫描操作有效,但不支持文档编写器扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下参数使用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_dateend_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆