1
使用DynamoDb檢索行特定數據DynamoDB和「讀」功能提供here我怎麼會去只檢索特定項目(例如只有名字,姓氏和城市)
我可能不得不添加某種過濾器,但是我無法找到任何我可以使用的東西。
這是我的表結構(與bpNumber是主鍵):
Item:{
"salutationCode": "02",
"lastName1": "Berg",
"firstName": "Anne",
"street": "Am Dächle",
"streetNumber": "22/2",
"zipcode": "33425",
"countryCode": "DE",
"city": "Hausen",
"bpNumber": 222,
"dateOfBirth": "1955-07-01",
"attri": [
{
"attri1":"nonono"
},
{
"attri2": "yeayeayea"
}
]
}
這種 「讀」 的方法我用:
read(){
var docClient = new AWS.DynamoDB.DocumentClient()
var table = "businessPartnersData";
var bpNumber = 222;
var params = {
TableName: table,
Key:{
"bpNumber": bpNumber
}
};
docClient.get(params, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
}
});
}
謝謝你的時間!
真棒,謝謝。大概應該是我自己發現的。 –