dynamodb node aws-sdk simple getItem() call

后端 未结 3 655
独厮守ぢ
独厮守ぢ 2021-02-04 06:20

Folks, New to Javascript... trying to do simple dynamo queries from node:

var AWS = require(\'aws-sdk\');
AWS.config.update({region: \'us-east-1\'});
var db = ne         


        
3条回答
  •  误落风尘
    2021-02-04 06:51

    Must follow the SDK and Docs, its simple: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html

    var params = {
        AttributesToGet: [
          "password"
        ],
        TableName : 'foo',
        Key : { 
          "username" : {
            "S" : "bar"
          }
        }
      }
    
      db.getItem(params, function(err, data) {
        if (err) {
          console.log(err); // an error occurred
          } 
        else {
          console.log(data); // successful response
          res.send(data);
          }
        return next();
      });
    

提交回复
热议问题