<tfoot id='3MJ4Z'></tfoot>
    <bdo id='3MJ4Z'></bdo><ul id='3MJ4Z'></ul>
<legend id='3MJ4Z'><style id='3MJ4Z'><dir id='3MJ4Z'><q id='3MJ4Z'></q></dir></style></legend>

      1. <small id='3MJ4Z'></small><noframes id='3MJ4Z'>

        <i id='3MJ4Z'><tr id='3MJ4Z'><dt id='3MJ4Z'><q id='3MJ4Z'><span id='3MJ4Z'><b id='3MJ4Z'><form id='3MJ4Z'><ins id='3MJ4Z'></ins><ul id='3MJ4Z'></ul><sub id='3MJ4Z'></sub></form><legend id='3MJ4Z'></legend><bdo id='3MJ4Z'><pre id='3MJ4Z'><center id='3MJ4Z'></center></pre></bdo></b><th id='3MJ4Z'></th></span></q></dt></tr></i><div id='3MJ4Z'><tfoot id='3MJ4Z'></tfoot><dl id='3MJ4Z'><fieldset id='3MJ4Z'></fieldset></dl></div>
      2. Dynamodb 过滤器表达式不返回所有结果

        时间:2023-08-08
        • <bdo id='X5K1e'></bdo><ul id='X5K1e'></ul>
        • <legend id='X5K1e'><style id='X5K1e'><dir id='X5K1e'><q id='X5K1e'></q></dir></style></legend>
            <i id='X5K1e'><tr id='X5K1e'><dt id='X5K1e'><q id='X5K1e'><span id='X5K1e'><b id='X5K1e'><form id='X5K1e'><ins id='X5K1e'></ins><ul id='X5K1e'></ul><sub id='X5K1e'></sub></form><legend id='X5K1e'></legend><bdo id='X5K1e'><pre id='X5K1e'><center id='X5K1e'></center></pre></bdo></b><th id='X5K1e'></th></span></q></dt></tr></i><div id='X5K1e'><tfoot id='X5K1e'></tfoot><dl id='X5K1e'><fieldset id='X5K1e'></fieldset></dl></div>

              <tbody id='X5K1e'></tbody>

            <tfoot id='X5K1e'></tfoot>

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

                  本文介绍了Dynamodb 过滤器表达式不返回所有结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想扫描过去 7 天的所有项目,所以我要做的是生成 7 天前的时间戳并过滤大于该值的时间戳.但此扫描返回了一些结果.

                  I want to scan all items for last 7 days, so what I do is I generate timestamp for 7 days back and filter for timestamp greater than that value. But this scan is returning a few results.

                  请参阅以下 Javascript:

                  See the following Javascript:

                  const daysBack = (days) => {
                    let date = new Date();
                    date.setDate(date.getDate() - days);
                    return date.getTime() ; 
                  }
                  
                  
                  const params = {
                    TableName: process.env.DYNAMODB_TABLE,
                    FilterExpression: "#ts > :z",
                    ExpressionAttributeNames:{
                        "#ts": "timestamp"
                    },
                    ExpressionAttributeValues: {
                        ":z": daysBack(7)
                    },
                  };
                  
                  dynamoDb.scan(params, (error, result) => {
                    // ... 
                  }
                  

                  推荐答案

                  这是因为在 SCAN 操作上 dynamoDb 只会发送 最多 1mb 的数据.如果您想要的记录大小超过 1mb,则会自动分页.

                  It is because on a SCAN operation dynamoDb will only send data upto 1mb only. If the records you want are of size more than 1mb automatically pagination happens.

                  如果你记录你的结果,那么你会发现一个名为 LastEvaluatedKey 的属性如果此属性存在,那么您将不得不再次调用以获取剩余数据.此调用必须递归实现,并且您必须在 LastEvaluatedKey 属性不存在时停止它.

                  If you log your Result then you will find an attribute called LastEvaluatedKey if this attribute is present then you will have to make another call to get the remaining data. This call has to be implemented recursively and you have to stop it when LastEvaluatedKey attribute is not present.

                  让我们看看这个例子,项目数据被递归获取,整个数据被附加到数组中,然后发送.

                  Lets see this example where project data is been fetched recursively and the whole data is appended in the array and then send.

                  let getFromDb = function (params, callback) {
                      params.ConsistentRead = true;
                      let projectCollection = [];
                      dynamodbclient.scan(params, onQuery);
                  
                      function onQuery(err, data) {
                          const methodName = 'onQuery';
                          if (err) {
                              callback(err);
                              log.error(err, {
                                  class: className,
                                  func: methodName
                              });
                          } else {
                              for (let i = constant.LENGTH_ZERO; i < data.Items.length; i++) {
                                  projectCollection.push(data.Items[i]);
                              }
                              if (typeof data.LastEvaluatedKey !== 'undefined') {
                                  params.ExclusiveStartKey = data.LastEvaluatedKey;
                                  dynamodbclient.scan(params, onQuery);
                              } else {
                                  callback(err, projectCollection); //recursive call
                              }
                          }
                      }
                  }; 
                  

                  这篇关于Dynamodb 过滤器表达式不返回所有结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Firebase 警告:使用未指定的索引 下一篇:如何计算猫鼬中具有一个不同字段的记录?

                  相关文章

                  最新文章

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

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

                    1. <tfoot id='b8qcB'></tfoot>
                      <legend id='b8qcB'><style id='b8qcB'><dir id='b8qcB'><q id='b8qcB'></q></dir></style></legend>