DynamoDb: запрос элементов между двумя датами - PullRequest
0 голосов
/ 30 августа 2018

Мне не очень повезло с этим запросом, он возвращает 0 пунктов

const { Items } = await this.dynamoDb.query({
  TableName: 'exampleTableName',
  IndexName: 'createdDateTime-index',
  KeyConditionExpression: '#createdDateTime BETWEEN :fromDateTime AND :toDateTime AND #status = :status',
  ExpressionAttributeNames: {
    '#status': 'status',
    '#createdDateTime': 'createdDateTime',
  },
  ExpressionAttributeValues: {
    ':fromDateTime': '2017-02-20T01:58:49.710Z',
    ':toDateTime': new Date().toISOString(),
    ':status': 'SUCCESS',
  },
}).promise();

У меня есть один элемент в БД:

{
  "id": "fa47003a-983a-4dc3-a87e-ace73ea7e451",
  "createdDateTime": "2018-02-20T02:58:49.710Z",
  "status": "SUCCESS"
}

Таблица:

aws dynamodb create-table \
  --endpoint-url http://localhost:8000 \
  --table-name exampleTableName \
  --attribute-definitions \
    AttributeName=id,AttributeType=S \
    AttributeName=status,AttributeType=S \
    AttributeName=createdDateTime,AttributeType=S \
  --key-schema \
    AttributeName=id,KeyType=HASH \
  --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=10 \
  --global-secondary-indexes \
    IndexName=createdDateTime-index,KeySchema=["{AttributeName=status,KeyType=HASH},{AttributeName=createdDateTime,KeyType=RANGE}"],Projection="{ProjectionType=ALL}",ProvisionedThroughput="{ReadCapacityUnits=10,WriteCapacityUnits=10}"

Я ожидаю, что 2018-02-20T02: 58: 49.710Z упадет между 2017-08-30T03: 11: 22.627Z и сейчас.

Можете ли вы помочь с запросом?

1 Ответ

0 голосов
/ 03 сентября 2018

Как уже упоминалось @cementblocks, запрос работает как положено.

...