-1
所以我有一個10個項目的表格,每個項目有大約5個鍵(名稱,經驗,水平等)。現在,我想掃描該表,將每個項目作爲對象並將其添加到數組,然後JSON對該數組進行字符串化並將其返回。如何掃描lambda中的dynamoDB?
我只需要掃描代碼的幫助,並獲取所有項目並將其放入數組中。
這是我目前的代碼。
var dynamodb = new AWS.DynamoDB.DocumentClient();
exports.handler = function(event, context, callback)
{
var returnArray = {
"cards": {}
}
getCards();
function getCards() {//Not sure how to write this function
var params = {
TableName : "toBeApprovedTable",
Key: {//not sure what to put here, since I want all items, and not searching through keys.
},
};
dynamodb.scan(params,function(err,data)
{
if(err)
{
console.log("error in scanning");
}
else
{
console.log("scanning success!");
//Not sure what to do here.
}
});
}
};
放下評論,如果你需要我解釋一行:) – TheQ