DynamoDB query Bug in KeyConditionExpression

0

I'm using lambda to query items my issues are:

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'
                            }
  };

This is working fine but when I'm changing the value of ExpressionAttributeValues such as ':value': to hii I'm getting error. Also when I'm changing the ':end': isoString to ':end': '2022-07-21T10:49:47.720Z' or ':start':'2022-06-16T03:47:35.343Z' to ```':start':'2022-07-21T10:49:47.720Z' , Im getting error:

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

Link: Demo for bug

1 Answer
0
Accepted Answer

Did you try simple ' (simple apostrophe) instead of double on "HI"?

profile pictureAWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions