我有一个 Dynamo 表,其中只有分区键 - “CreatedAt”和一些其他属性。
我想写一个查询,但我不会得到结果。CreatedAt 位于 LastSunday 和 Today 之间的项目的数量。
我已将日期以字符串格式存储为“2021-03-09T14:33:29Z”。
我不想使用 GSI。
使用以下查询时,我收到错误 - “不支持查询关键条件”
这是我的代码:
var queryRequest = new QueryRequest
{
TableName = myTableName,
KeyConditionExpression = "CreatedAt BETWEEN :LastMonday AND :TodaysDate",
};
Dictionary<string, AttributeValue> expressionAttributeValues = new Dictionary<string, AttributeValue>();
expressionAttributeValues.Add(":TodaysDate", new AttributeValue { S = "2021-03-09T14:33:29Z" });
expressionAttributeValues.Add(":LastMonday", new AttributeValue { S = "2021-03-02T14:33:29Z" });
queryRequest.ExpressionAttributeValues = expressionAttributeValues;
var response = await awsDynamoClient.QueryAsync(queryRequest);
Run Code Online (Sandbox Code Playgroud)