0
此代码返回整套物品,我只需要计数它的数量。是否有可能只获得这个索引的项目数?DynamoDB获取物品计数
AWSDynamoDBObjectMapper *objectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
AWSDynamoDBQueryExpression *queryExpression = [AWSDynamoDBQueryExpression new];
queryExpression.indexName = @"getVideoViews";
queryExpression.keyConditionExpression = @"#videoId = :val";
queryExpression.expressionAttributeNames = @{
@"#videoId" : @"videoId",
};
queryExpression.expressionAttributeValues = @{
@":val": videoId,
};
__weak typeof(self) weakSelf = self;
[objectMapper query:[ViewedVideos class]
expression:queryExpression
completionHandler:^(AWSDynamoDBPaginatedOutput * _Nullable response, NSError * _Nullable error) {
if (!error) {
dispatch_async(dispatch_get_main_queue(), ^{
if ([weakSelf.delegate respondsToSelector:@selector(serverConnectionHandlerReceivedNumberOfVideoViews:)]) {
[weakSelf.delegate serverConnectionHandlerReceivedNumberOfVideoViews:3];
}
});
}
}];
喜欢这里例如:
aws dynamodb scan --table-name <TABLE_NAME> --select "COUNT"
itemcount是否适用于查询?因为,我不希望整个表的数量,但只有具有该videoID项目的数量。 – vatti
根据:http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html 您可以使用** Count **参数来获取与过滤条件匹配的项目总数用于扫描/查询 –
是的,但它会返回所有项目,并且您还有count参数。我只需要返回count参数,而不是项目。对不起,如果我错过了一些东西。 – vatti