I am trying to implement user registration and login using DynamoDB. There's three ways a user can login. They can use username, phone Number or Email Id to login. My DynamoDB table has Phone Number as hash in primary index and thus I am able to load it properly using -
[[dynamoDBObjectMapper load:AWSUserWithPhone hashKey:hashkey rangeKey:nil]
continueWithBlock:^id(BFTask *task) {
if (task.error) {
NSLog(@"The request failed. Error: [%@]", task.error);
}
if (task.exception) {
NSLog(@"The request failed. Exception: [%@]", task.exception);
}
if (task.result) {
if(completionBlock)
completionBlock(task.result);
}
return nil;
}];
But I am unable to use the same method for Username and Email. I get the following error when I try username or email instead -
2015-04-27 19:01:42.549 Barnc[691:122171] AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:86 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: [{"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema"}]
2015-04-27 19:01:42.556 Barnc[691:122171] The request failed. Error: [Error Domain=com.amazonaws.AWSDynamoDBErrorDomain Code=0 "The operation couldn’t be completed. (com.amazonaws.AWSDynamoDBErrorDomain error 0.)" UserInfo=0x17b96ed0 {message=The provided key element does not match the schema, __type=com.amazon.coral.validate#ValidationException}]
Here's the details of the table
and here's the secondary global indices -
(Sorry for the images instead of text, I was not sure how to show it properly here.)
Is there something else required to access secondary indices? I am interested in using the last two indices to load user using username or email.
Aucun commentaire:
Enregistrer un commentaire