此代码返回整个项目集,我只需要它的计数。是否可以仅获取该索引的项目数?
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"