DynamoDB中KeyConditionExpression查询中存在Bug。

0

【以下的问题经过翻译处理】 我正在使用Lambda查询事项,我的问题是:

const now = new Date();
const isoString = now.toISOString();

const params = {
  TableName: 'Todo-xxxxxxxxxxxxxxxxxxxx-dev',
  IndexName: 'title-createdAt-index',
  "Limit": 10,
  KeyConditionExpression: '#title =:value and #createdAt BETWEEN :start AND :end',
  ExpressionAttributeValues: { ':value':  "hi",
                                  ':start':'2022-06-16T03:47:35.343Z',
                                  ':end':  isoString },
  ExpressionAttributeNames: { '#title': 'title',
                              '#createdAt':'createdAt'
                            }
  };

这个代码很好用,但当我更改ExpressionAttributeValues的值,例如将':value':改为hii时,我会遇到错误。 当我将':end': isoString更改为':end': '2022-07-21T10:49:47.720Z'':start':'2022-06-16T03:47:35.343Z'更改为':start':'2022-07-21T10:49:47.720Z'时,我会遇到错误:

{
  "errorType": "TypeError",
  "errorMessage": "Cannot read properties of undefined (reading 'id')",
  "trace": [
    "TypeError: Cannot read properties of undefined (reading 'id')",
    "    at Runtime.exports.handler (/var/task/index.js:85:29)",
    "    at processTicksAndRejections (node:internal/process/task_queues:96:5)"
  ]
}

链接:演示错误

profile picture
专家
已提问 5 个月前45 查看次数
1 回答
0

【以下的回答经过翻译处理】 你尝试过在“HI”上使用单引号(')而不是双引号吗?

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则