dynamodb中的保留关键字-Swift 3 [英] reserved keyword in dynamodb - Swift 3
问题描述
这里是代码:
queryExpression.keyConditionExpression = "#userId= :userId"
queryExpression.expressionAttributeNames = ["#userId":"userId", "#status":"status"]
queryExpression.expressionAttributeValues = [":userId":userID, ":status":"accept"]
queryExpression.projectionExpression = "status"
,但是出现以下错误,但我不知道状态字是保留字DynamoDB中的单词:
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}
下面的链接,但我不理解,也找不到Swift的示例。我该如何完成?
http:// docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html#Expressions.ExpressionAttributeNames.ReservedWords
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
我是DynamoDB的新手。
I am new to DynamoDB things.
谢谢!
推荐答案
以下是所有列表DynamoDB中的保留字:
http://docs.aws .amazon.com / amazondynamodb / latest / developerguide / ReservedWords.html
Here is a list of all the reserved words in DynamoDB: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html
so ExpressionAttributeNames
和 expressionAttributeValues
是使用 #fooattribute
和:foovalue
的别名方式即使 foo
是上面列表中的保留字。
so ExpressionAttributeNames
and expressionAttributeValues
are ways of aliasing to use #fooattribute
and :foovalue
even if foo
were a reserved word within the above list.
因此,在您的情况下,我相信您的错误是因为保留术语 status
,您可以尝试将最后一行更改为:
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.
这篇关于dynamodb中的保留关键字-Swift 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!