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)"
  ]
}

链接:演示错误

1 Antwort
0

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

profile picture
EXPERTE
beantwortet vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen