amazon web services - Only retrieve specific data from a row in DynamoDB using JavaScript - Stack Overflow

Using DynamoDb and the "read" function provided here how would I go about only retrieving spec


Using DynamoDb and the "read" function provided here how would I go about only retrieving specific items (e.g. only firstname, lastname and city)
I would probably have to add some kind of filter, however i was not able to find anything that I could use.

This is my table structure (with bpNumber being the primary key):

Item:{
            "salutationCode": "02",
            "lastName1": "Berg",
            "firstName": "Anne",
            "street": "Am Dächle",
            "streetNumber": "22/2",
            "zipcode": "33425",
            "countryCode": "DE",
            "city": "Hausen",
            "bpNumber": 222,
            "dateOfBirth": "1955-07-01",
            "attri": [
              {
                "attri1":"nonono"
              },
              {
                "attri2": "yeayeayea"
              }
            ]

        }

and this the "read" method I'm using:

read(){
        var docClient = new AWS.DynamoDB.DocumentClient()

        var table = "businessPartnersData";

        var bpNumber = 222;

        var params = {
            TableName: table,
            Key:{
                "bpNumber": bpNumber
            }
        };

        docClient.get(params, function(err, data) {
            if (err) {
                console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
            } else {
                console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
            }
        });
  }

Thank you for you time!


Using DynamoDb and the "read" function provided here how would I go about only retrieving specific items (e.g. only firstname, lastname and city)
I would probably have to add some kind of filter, however i was not able to find anything that I could use.

This is my table structure (with bpNumber being the primary key):

Item:{
            "salutationCode": "02",
            "lastName1": "Berg",
            "firstName": "Anne",
            "street": "Am Dächle",
            "streetNumber": "22/2",
            "zipcode": "33425",
            "countryCode": "DE",
            "city": "Hausen",
            "bpNumber": 222,
            "dateOfBirth": "1955-07-01",
            "attri": [
              {
                "attri1":"nonono"
              },
              {
                "attri2": "yeayeayea"
              }
            ]

        }

and this the "read" method I'm using:

read(){
        var docClient = new AWS.DynamoDB.DocumentClient()

        var table = "businessPartnersData";

        var bpNumber = 222;

        var params = {
            TableName: table,
            Key:{
                "bpNumber": bpNumber
            }
        };

        docClient.get(params, function(err, data) {
            if (err) {
                console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
            } else {
                console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
            }
        });
  }

Thank you for you time!

Share asked Aug 25, 2016 at 7:36 weggi_swaweggi_swa 3301 gold badge5 silver badges12 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 9

You can use ProjectionExpression:

params.ProjectionExpression = "firstname, lastname, city";

This will only return these attributes in the resultset, for all items.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745052904a4608492.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信