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

      <legend id='sGNhS'><style id='sGNhS'><dir id='sGNhS'><q id='sGNhS'></q></dir></style></legend>
        • <bdo id='sGNhS'></bdo><ul id='sGNhS'></ul>

        <tfoot id='sGNhS'></tfoot>
      1. <small id='sGNhS'></small><noframes id='sGNhS'>

        dynamodb.put().promise() 不返回 put 对象

        时间:2023-09-03

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

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

        • <tfoot id='PZNks'></tfoot>

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

                  本文介绍了dynamodb.put().promise() 不返回 put 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使用 async/await 与 aws 和 dynamo db 相关的功能.下面是一个如何在异步等待之前放置对象的示例,正​​如您在回调中看到的那样,您可以访问包含放置对象的数据.然而,在使用 async 和 promise 的第二个代码块中,结果是一个空对象,有什么想法吗?

                  I am trying to make use of the async/await functionality with regard to aws and dynamo db. Below is an example of how to put an object pre asyn await, as you can see in the callback you have access to data which contains the put object. However in the second block of code which uses async and promise the result is an empty object, any thoughts?

                  https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.NodeJs.03.html

                  非承诺版本

                  var docClient = new AWS.DynamoDB.DocumentClient();
                  
                  var table = "Movies";
                  
                  var year = 2015;
                  var title = "The Big New Movie";
                  
                  var params = {
                      TableName:table,
                      Item:{
                          "year": year,
                          "title": title,
                          "info":{
                              "plot": "Nothing happens at all.",
                              "rating": 0
                          }
                      }
                  };
                  
                  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));
                      }
                  });
                  

                  Promise async 版本 - 假设包装函数被标记为异步

                  var docClient = new AWS.DynamoDB.DocumentClient();
                  
                  var table = "Movies";
                  
                  var year = 2015;
                  var title = "The Big New Movie";
                  
                  var params = {
                      TableName:table,
                      Item:{
                          "year": year,
                          "title": title,
                          "info":{
                              "plot": "Nothing happens at all.",
                              "rating": 0
                          }
                      }
                  };
                  const result: any = await dynamoDb.put(params).promise()
                  console.log(result) 
                  

                  推荐答案

                  根据doc 如果你想要返回一些东西,你必须使用 ReturnValues.

                  According to the doc you have to use ReturnValues if you want something back.

                  这篇关于dynamodb.put().promise() 不返回 put 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 dynamodb 中使用 batchWriteItem 下一篇:如何使用 AWS JavaScript SDK (dynamoDB) 处理 Unprocessed

                  相关文章

                  最新文章

                  <legend id='GZzAS'><style id='GZzAS'><dir id='GZzAS'><q id='GZzAS'></q></dir></style></legend>
                1. <small id='GZzAS'></small><noframes id='GZzAS'>

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

                      <tfoot id='GZzAS'></tfoot>