我正在尝试在缩略图字段中注册Standard JSON
为JSDynamoDB
使用aws-sdk 版本 3。
在版本 2 中允许使用该put
方法,在版本 3 中现在是命令,但我没有看到等效的命令。
我的代码:
const { DynamoDBClient, PutItemCommand } = require('@aws-sdk/client-dynamodb');
const DynamoDBDocClient = new DynamoDBClient({ region: "us-east-1"});
const item = {
PK: "My_pk",
SK: "My_sk",
username: "My_username",
thumbnail: {
id: "My_id",
width: "My_width",
height: "My_height"
}
}
const params = {
Item: item,
TableName: "My_table"
};
await DynamoDBDocClient.send(new PutItemCommand(params));
错误:
ERROR TypeError: Cannot read property '0' of undefined
at Object.visit (/var/task/node_modules/@aws-sdk/client-dynamodb/dist/cjs/models/models_0.js:1101:40)
at serializeAws_json1_0AttributeValue (/var/task/node_modules/@aws-sdk/client-dynamodb/dist/cjs/protocols/Aws_json1_0.js:4612:38)
at /var/task/node_modules/@aws-sdk/client-dynamodb/dist/cjs/protocols/Aws_json1_0.js:5514:20
at Array.reduce (<anonymous>)
我只能注册它使用的项目marshall
(来自@aws-sdk/util-dynamodb
),但它注册为DynamoDB JSON
: