Node.js DynamoDb:两个日期之间的查询项
我对这个查询运气不好,它返回0项Node.js DynamoDb:两个日期之间的查询项,node.js,amazon-dynamodb,aws-sdk,dynamodb-queries,Node.js,Amazon Dynamodb,Aws Sdk,Dynamodb Queries,我对这个查询运气不好,它返回0项 const { Items } = await this.dynamoDb.query({ TableName: 'exampleTableName', IndexName: 'createdDateTime-index', KeyConditionExpression: '#createdDateTime BETWEEN :fromDateTime AND :toDateTime AND #status = :status', Expressi
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();
我在DB中有一项:
{
"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和现在之间
您能帮我查询一下吗?表中的完整项是什么?您显示的一个不正确,它缺少
id
属性?抱歉@cencoblocks在数据样本中添加了缺少的id字段您的查询对我有效,使用您的表定义和对象。你是否在nodejs代码中命中了本地端点?我不知道为什么这对我不起作用。现在有了。必须与我的本地设置有关。。。