使用AWS java脚本接口将项目插入dynamo db本地表时,发电机数据库获取错误未定义docClient。如何初始化docClient?以下是导致问题的代码。
enter var params = {
TableName: "ADV_Admin",
Item: { "jdate": 45455455411444411,"name": "xyz abc", "pwd": sdewrfsdzs",
"roles": "[\"ADMIN\",\"USER\"]", "st": "R", "uname": "admin"}
};
docClient.put(params, function(err, data) {
if (err)
console.log(JSON.stringify(err, null, 2));
else
console.log(JSON.stringify(data, null, 2));
});
答案 0 :(得分:1)
在使用docClient之前,您必须在某处定义它,如下所示:
var AWS = require('aws-sdk'); // you probably have this line somewhere already
var docClient = new AWS.DynamoDB.DocumentClient();