2016-10-04 12 views
0

私は多くのvideoIdsの項目を取得したいのですが、このコードのように1つのビデオ項目だけはありませんか?インデックスから複数のアイテムをクエリする方法はありますか?DynamoDB(iOS)の複数の項目を照会する方法は?

AWSDynamoDBObjectMapper *objectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper]; 
AWSDynamoDBQueryExpression *queryExpression = [AWSDynamoDBQueryExpression new]; 

queryExpression.indexName = @"getVideoItem"; 
queryExpression.keyConditionExpression = @"#id = :id"; 
queryExpression.expressionAttributeNames = @{ 
              @"#id" : @"id", 
              }; 
queryExpression.expressionAttributeValues = @{ 
               @":id" : videoId, 
               }; 
__weak typeof(self) weakSelf = self; 

[objectMapper query:[PublicVideos class] 
     expression:queryExpression 
    completionHandler:^(AWSDynamoDBPaginatedOutput * _Nullable response, NSError * _Nullable error) { 
     if (!error) { 
      dispatch_async(dispatch_get_main_queue(), ^{ 
       if ([weakSelf.delegate respondsToSelector:@selector(ServerConnectionHandlerVideoListRecevied:)]) { 
        [weakSelf.delegate ServerConnectionHandlerVideoListRecevied:response.items]; 
       } 
      }); 
     } 
    }]; 

答えて

0

テーブルのスキーマはどのように見えますか? テーブルに対してハッシュキーとレンジキーの両方を有効にしていますか?範囲キーがない場合は、ハッシュキーごとに1つのエントリしかなく、クエリでは1つの行しか返されません。

あなたはハッシュキーとRANGEキーの両方を持っている場合、あなたはこのようなもので照会:

AWSDynamoDBObjectMapper *objectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper]; 
AWSDynamoDBQueryExpression *queryExpression = [AWSDynamoDBQueryExpression new]; 
queryExpression.indexName = @"Artist-Album-index"; 
queryExpression.keyConditionExpression = @"#artist = :artist AND #album < :album"; 
queryExpression.expressionAttributeNames = @{ 
               @"#artist" : @"Artist", 
               @"#album" : @"Album", 
               }; 
queryExpression.expressionAttributeValues = @{ 
                @":artist" : @"valuetosearch", 
                @":album" : @"valuetosearch", 
                }; 
[objectMapper query:[Song class] 
      expression:queryExpression 
     completionHandler:^(AWSDynamoDBPaginatedOutput * _Nullable response, NSError * _Nullable error) { 
      dispatch_async(dispatch_get_main_queue(), ^{ 
       // handle response 
      }); 
     }]; 

ここでは上記のスニペットでは、それは<」の条件に合致するアーティストのためのすべてのアルバムを探してしようとします

関連する問題