Here is code:
queryExpression.keyConditionExpression = "#userId= :userId"
queryExpression.expressionAttributeNames = ["#userId":"userId", "#status":"status"]
queryExpression.expressionAttributeValues = [":userId":userID, ":status":"accept"]
queryExpression.projectionExpression = "status"
but I got the following error and I didnt know that status word is a reserved word in DynamoDB:
Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=0 "(null)" UserInfo={message=Invalid ProjectionExpression: Attribute name is a reserved keyword; reserved keyword: status, __type=com.amazon.coral.validate#ValidationException}
I have looked at the below link but I do not understand it and I can't find a Swift example. How do I accomplish this? http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html#Expressions.ExpressionAttributeNames.ReservedWords
I am new to DynamoDB things.
Thanks!
Here is a list of all the reserved words in DynamoDB: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html
so
ExpressionAttributeNames
andexpressionAttributeValues
are ways of aliasing to use#fooattribute
and:foovalue
even iffoo
were a reserved word within the above list.So in your case, I believe your error is because the term
status
is reserved, you may try changing your last line to be :queryExpression.projectionExpression = "#status"
That way you wouldn't be using the reserved word, it would read the alias instead. That alias would resolve to your actual attribute name which might as well be status.