dynamodb node aws-sdk simple getItem() call

后端 未结 3 664
独厮守ぢ
独厮守ぢ 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:40

    I was trying to do it as it was suggested in the documentation, but also got errors.

    At the end the following worked:

    var aws = require('aws-sdk');
    var db = new aws.DynamoDB({
      region: 'eu-central-1',
      maxRetries: 1
    });
    
    exports.handler = event => {
        return queryMyThings();
    }
    
    const queryMyThings = async (event) => { 
     var params = {
          Key: {
          "ColumnByWhichYouSearch": {
             S: "ValueThatYouAreQueriing"
            }
          }, 
          TableName: "YourTableName"
         };
    
        return await db.getItem(params).promise();
    
    }
    

提交回复
热议问题