<i id='u1roZ'><tr id='u1roZ'><dt id='u1roZ'><q id='u1roZ'><span id='u1roZ'><b id='u1roZ'><form id='u1roZ'><ins id='u1roZ'></ins><ul id='u1roZ'></ul><sub id='u1roZ'></sub></form><legend id='u1roZ'></legend><bdo id='u1roZ'><pre id='u1roZ'><center id='u1roZ'></center></pre></bdo></b><th id='u1roZ'></th></span></q></dt></tr></i><div id='u1roZ'><tfoot id='u1roZ'></tfoot><dl id='u1roZ'><fieldset id='u1roZ'></fieldset></dl></div>

        • <bdo id='u1roZ'></bdo><ul id='u1roZ'></ul>

        <tfoot id='u1roZ'></tfoot><legend id='u1roZ'><style id='u1roZ'><dir id='u1roZ'><q id='u1roZ'></q></dir></style></legend>

        <small id='u1roZ'></small><noframes id='u1roZ'>

        AWS - 所需键之一未指定值

        时间:2023-09-03

          <legend id='WZZ4z'><style id='WZZ4z'><dir id='WZZ4z'><q id='WZZ4z'></q></dir></style></legend>
          <tfoot id='WZZ4z'></tfoot>
          <i id='WZZ4z'><tr id='WZZ4z'><dt id='WZZ4z'><q id='WZZ4z'><span id='WZZ4z'><b id='WZZ4z'><form id='WZZ4z'><ins id='WZZ4z'></ins><ul id='WZZ4z'></ul><sub id='WZZ4z'></sub></form><legend id='WZZ4z'></legend><bdo id='WZZ4z'><pre id='WZZ4z'><center id='WZZ4z'></center></pre></bdo></b><th id='WZZ4z'></th></span></q></dt></tr></i><div id='WZZ4z'><tfoot id='WZZ4z'></tfoot><dl id='WZZ4z'><fieldset id='WZZ4z'></fieldset></dl></div>
        1. <small id='WZZ4z'></small><noframes id='WZZ4z'>

            • <bdo id='WZZ4z'></bdo><ul id='WZZ4z'></ul>

                  <tbody id='WZZ4z'></tbody>

                1. 本文介绍了AWS - 所需键之一未指定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  AWS 新手,试图将数据放入表中.阅读文档并尝试遵循示例后,我遇到了此验证错误.

                  New to AWS, trying to put data into a table. After reading the documentation and trying to follow examples I am running into this validation error.

                  One of the required keys was not given a value
                  

                  我的代码:

                  var conf = require("/directory");
                  var AccessKey = 'supersecretkey';
                  var SecretKey = 'supersecretkey';
                  
                  var tableName = conf.tableCS;
                  
                  var AWS = require('aws-sdk');
                  
                  console.log("Endpoint: " + conf.endpoint);
                  AWS.config.update({
                      accessKeyId: AccessKey,
                      secretAccessKey: SecretKey,
                      region: conf.region,
                      endpoint: conf.endpoint
                  });
                  var docClient = new AWS.DynamoDB.DocumentClient();
                  
                  var file = process.argv[2];
                  console.log("File: " + file);
                  
                  var csv = require("fast-csv");
                  
                  csv.fromPath(file)
                      .on("data", function(data) {
                          // Uncomment to see CSV data
                          // console.log(data);
                  
                          var arrayLength = data.length;
                          for (var i = 0; i < arrayLength; i++) {
                              // console.log(data[i]);
                              var params = {
                                  TableName: tableName,
                                  Key: {
                                         RefID: data
                                  }
                              };
                  
                              console.log("Adding a new item...");
                              docClient.put(params, function(err, data) {
                                  if (err) {
                                      console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
                                  }
                                  else {
                                      console.log("Added item:", JSON.stringify(data, null, 2));
                                  }
                              });
                              // Looping through, now putItem into database
                          }
                  
                      })
                      .on("end", function() {
                          console.log("done");
                      });
                  

                  我找到了 这个,但我不理解 range 关键部分.我正在以下代码中创建表,并且有 hash 键,但没有 range 键.那是我的问题吗?我将如何制作范围键?

                  I found this, but am not understanding the range key part. I'm creating the table in this following code and have the hash key, but not a range key. Is that my issue? What would I make the range key?

                  var conf = require("/directory");
                  var AccessKey = 'supersecretkey';
                  var SecretKey = 'supersecretkey';
                  
                  var tableName = conf.tableCSV;
                  
                  // Take input from command line
                  process.argv.forEach(function(val, index, array) {
                      console.log(index + ': ' + val);
                  });
                  
                  console.log("Table: " + tableName);
                  
                  var AWS = require('aws-sdk');
                  
                  console.log("Endpoint: " + conf.endpoint);
                  AWS.config.update({
                      accessKeyId: AccessKey,
                      secretAccessKey: SecretKey,
                      region: conf.region,
                      endpoint: conf.endpoint
                  });
                  var dynamodb = new AWS.DynamoDB();
                  
                  var params = {
                      TableName: tableName,
                      KeySchema: [{
                          AttributeName: 'RefID',
                          KeyType: 'HASH'
                      }],
                      AttributeDefinitions: [{
                          AttributeName: 'RefID',
                          AttributeType: 'S'
                      }],
                      ProvisionedThroughput: {
                          ReadCapacityUnits: 1,
                          WriteCapacityUnits: 1
                      }
                  };
                  
                  dynamodb.createTable(params, function(err, table) {
                      if (err) {
                          console.log(err);
                      }
                      else {
                          console.log("TABLED CREATED");
                          console.log(table);
                      }
                  });
                  

                  推荐答案

                  在表定义中,您将键命名为 Ref-ID,但在 put 操作中,您将键命名为 Info.如果您的表有一个名为 Ref-ID 的哈希键,那么您插入的每条记录都需要 Ref-ID 的值.

                  In the table definition, you named the key Ref-ID but in your put operation you are naming the key Info. If your table has a hash key named Ref-ID then every record you insert will require a value for Ref-ID.

                  这篇关于AWS - 所需键之一未指定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <tfoot id='76pLw'></tfoot>
                      <bdo id='76pLw'></bdo><ul id='76pLw'></ul>
                      <i id='76pLw'><tr id='76pLw'><dt id='76pLw'><q id='76pLw'><span id='76pLw'><b id='76pLw'><form id='76pLw'><ins id='76pLw'></ins><ul id='76pLw'></ul><sub id='76pLw'></sub></form><legend id='76pLw'></legend><bdo id='76pLw'><pre id='76pLw'><center id='76pLw'></center></pre></bdo></b><th id='76pLw'></th></span></q></dt></tr></i><div id='76pLw'><tfoot id='76pLw'></tfoot><dl id='76pLw'><fieldset id='76pLw'></fieldset></dl></div>

                          <tbody id='76pLw'></tbody>
                        1. <small id='76pLw'></small><noframes id='76pLw'>

                          <legend id='76pLw'><style id='76pLw'><dir id='76pLw'><q id='76pLw'></q></dir></style></legend>