在我的参数@AWS Lambda node.js中始终获取“ String”而不是“ String”,有什么想法吗? (nodejs10.x)
从dynamodb流中获取带有字符串(userId)的记录,想要使用该字符串从dynamodb中读取更多项。
event.Records.forEach((record) => {
if (record.eventName == 'INSERT') {
var userId = JSON.stringify(record.dynamodb.NewImage.userId.S);
console.log('userId: ', userId);
// log: userId: "userid1234"
const params = {
Key: {
userId: {S: userId},
},
TableName: "test-table",
};
console.log("params ", params);
//params { userId: '"userid1234"' },
// not working
var pa = {
TableName: "test-table",
Key: {
'userId' : {"S": "userId"},
},
};
console.log("pa ", pa);
//pa { userId: 'userid1234' },
//working
dbCon.getItem(pa, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.Item);
}
});
}
“字符串”而不是“字符串”,我该怎么做?