简体   繁体   English

仅使用JavaScript从DynamoDB中的一行中检索特定数据

[英]Only retrieve specific data from a row in DynamoDB using JavaScript


Using DynamoDb and the "read" function provided here how would I go about only retrieving specific items (eg only firstname, lastname and city) 使用DynamoDb和此处提供的“读取”功能,我将如何只检索特定项目(例如,仅姓氏,姓氏和城市)
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): 这是我的表结构(以bpNumber为主键):

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! 谢谢您的时间!

You can use ProjectionExpression: 您可以使用ProjectionExpression:

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

This will only return these attributes in the resultset, for all items. 对于所有项目,这只会在结果集中返回这些属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Promises 从 DynamoDB 异步检索数据 - Retrieve Data from DynamoDB asynchronously using Promises 如何从getItem dynamoDB(JavaScript)检索特定对象? - How to retrieve specific object from a getItem dynamoDB (JavaScript)? 仅使用JavaScript从JSON提取的表格数据中单击按钮时引用特定行 - Refer specific row on click of button in table data fetched from JSON using only JavaScript 使用JavaScript从Firebase数据库中的特定节点检索数据 - Retrieve data from specific node in Firebase database using javascript 从 firebase Javascript 中检索特定数据 - Retrieve specific data from firebase Javascript 从另一个 HTML 文件中的表中检索特定行 - Javascript - Retrieve specific row from a table in another HTML file - Javascript 如何从URL检索HTML结构数据并使用javascript分析DOM特定数据 - how to retrieve HTML structure data from a url and analyse DOM specific data using javascript 是否可以使用 javascript SDK 从亚马逊 Dynamodb 查询 JSON 数据 - Is it possible to query JSON data from amazon Dynamodb using javascript SDK dynamodb使用javascript查询单行 - dynamodb query single row using javascript 如何使用Javascript从Firebase检索数据? - How to retrieve data from Firebase using Javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM