I am trying to query a global secondary index to see if a value exists. I am getting the error
Query condition missed key schema element: Username
I am querying using
AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
AWSDynamoDBQueryExpression *queryExpression = [AWSDynamoDBQueryExpression new];
queryExpression.hashKeyValues = textfieldUsername;
queryExpression.scanIndexForward = [NSNumber numberWithBool:YES];
queryExpression.limit = [NSNumber numberWithInt:1];
queryExpression.indexName = @"Username-index"; //using indexTable for query
[[dynamoDBObjectMapper query:[UsersDB class] expression:queryExpression] continueWithBlock:^id(BFTask *task) {
if (task.error) {
NSLog(@"Error: [%@]", task.error);
} else {
AWSDynamoDBPaginatedOutput *paginatedOutput;
paginatedOutput = task.result;
NSLog(@"pagin %@", paginatedOutput);
}
return nil;
}];
I was going to use LOAD instead of query but I understand it only searches the primary hash key and not the global one? I did make an additional database class with the secondary global index as the hash but this produced a key element does not match schema
error.
What am I doing wrong?
Username is a global secondary index
Aucun commentaire:
Enregistrer un commentaire