【发布时间】:2022-04-28 08:25:21
【问题描述】:
我正在使用 aws node.js sdk v3。我想使用 dynamodbdocumentclient 对表进行简单查询。我只想测试查询是否适用于 aws 开发人员指南提供的简单音乐表。
const data = await this.dynamoDBDocumentClient.send(new QueryCommand({
TableName: "Music",
KeyConditionExpression: "#Artist = :artist",
ExpressionAttributeName: {
"#Artist": "artist"
},
ExpressionAttributeValues: {
":artist": "Acme Band"
},
});
但是当我调用它时,我得到:
TypeError: Cannot read property '0' of undefined
当我做一个简单的时候:
const data = await.this.dynamoDBDocumentClient.send(newScanCommand({TableName: "Music"});
我得到了正确的回应:
{
"AlbumTitle": {
"S": "Somewhat Famous"
},
"Awards": {
"N": "1"
},
"Artist": {
"S": "No One You Know"
},
"SongTitle": {
"S": "Call Me Today"
}
},
{
"AlbumTitle": {
"S": "Songs About Life"
},
"Awards": {
"N": "10"
},
"Artist": {
"S": "Acme Band"
},
"SongTitle": {
"S": "Happy Day"
}
},
{
"AlbumTitle": {
"S": "Songs About Sadness"
},
"Awards": {
"N": "8"
},
"Artist": {
"S": "Acme Band"
},
"SongTitle": {
"S": "Sad Day"
}
}
],
"ScannedCount": 3
}```
What am I doing wrong? I don't get why I am getting en error.
【问题讨论】:
标签: amazon-web-services amazon-dynamodb dynamodb-queries