1. <small id='A4ryQ'></small><noframes id='A4ryQ'>

      <tfoot id='A4ryQ'></tfoot>
    1. <i id='A4ryQ'><tr id='A4ryQ'><dt id='A4ryQ'><q id='A4ryQ'><span id='A4ryQ'><b id='A4ryQ'><form id='A4ryQ'><ins id='A4ryQ'></ins><ul id='A4ryQ'></ul><sub id='A4ryQ'></sub></form><legend id='A4ryQ'></legend><bdo id='A4ryQ'><pre id='A4ryQ'><center id='A4ryQ'></center></pre></bdo></b><th id='A4ryQ'></th></span></q></dt></tr></i><div id='A4ryQ'><tfoot id='A4ryQ'></tfoot><dl id='A4ryQ'><fieldset id='A4ryQ'></fieldset></dl></div>
        <bdo id='A4ryQ'></bdo><ul id='A4ryQ'></ul>
    2. <legend id='A4ryQ'><style id='A4ryQ'><dir id='A4ryQ'><q id='A4ryQ'></q></dir></style></legend>

      使用 Swift 3 在 DynamoDB 中保留关键字 ExpressionAttr

      时间:2023-08-29
        • <small id='EocvJ'></small><noframes id='EocvJ'>

          <i id='EocvJ'><tr id='EocvJ'><dt id='EocvJ'><q id='EocvJ'><span id='EocvJ'><b id='EocvJ'><form id='EocvJ'><ins id='EocvJ'></ins><ul id='EocvJ'></ul><sub id='EocvJ'></sub></form><legend id='EocvJ'></legend><bdo id='EocvJ'><pre id='EocvJ'><center id='EocvJ'></center></pre></bdo></b><th id='EocvJ'></th></span></q></dt></tr></i><div id='EocvJ'><tfoot id='EocvJ'></tfoot><dl id='EocvJ'><fieldset id='EocvJ'></fieldset></dl></div>
            <tbody id='EocvJ'></tbody>
            <tfoot id='EocvJ'></tfoot>
            • <bdo id='EocvJ'></bdo><ul id='EocvJ'></ul>
              <legend id='EocvJ'><style id='EocvJ'><dir id='EocvJ'><q id='EocvJ'></q></dir></style></legend>
                本文介绍了使用 Swift 3 在 DynamoDB 中保留关键字 ExpressionAttributeValues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我能够在没有 :status : 接受表达式属性值的情况下获得响应,但是有了它,当我在 projectionExpression 行中使用 #status 时出现以下错误(status 是 DynamoDB 中的保留字,所以我有按 https://stackoverflow.com/a/45952329/5921575 在那里添加主题标签):

                I am able to get a response without the :status : accept expression attribute value but with it, I get the following error when I am using the #status in the projectionExpression line (status is a reserved word in DynamoDB so I had to add hashtag there per https://stackoverflow.com/a/45952329/5921575):

                Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=0 "(null)" 
                UserInfo={__type=com.amazon.coral.validate#ValidationException, 
                message=Value provided in ExpressionAttributeValues unused in expressions: keys: {:status}}
                

                代码如下:

                queryExpression.keyConditionExpression = "#userId= :userId"
                queryExpression.expressionAttributeNames = ["#userId":"userId", "#status":"status"]
                queryExpression.expressionAttributeValues = [":userId":userID, ":status":"accept"]
                queryExpression.projectionExpression = "#status"
                

                我可以不用 ":status":"accept" 但我不想得到很多没有接受值的项目.我在此链接或 stackoverflow 上的任何地方都找不到答案:http://docs.aws.amazon.com/amazondynamodb/最新/developerguide/Expressions.ExpressionAttributeNames.html

                I can go without the ":status":"accept" but I do not want to get a lot of items that do not have the accept value. I can't find an answer in this link or anywhere on stackoverflow: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html

                谢谢!

                推荐答案

                有点晚了,但是:你的投影表达式不应该是#status",而是另一个不是状态的词.Status 是保留字,所以不要将它用于投影表达式.有关需要使用保留字时该怎么做的文档,请参阅此处:https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html#Expressions.ExpressionAttributeNames.ReservedWords

                A bit late, but: Your projection expression should not be "#status" but another word that isn't status. Status is the reserved word, so don't use that for the projection expression. See here for docs on what to do when you need to use a reserved word: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html#Expressions.ExpressionAttributeNames.ReservedWords

                另一方面,userId 不需要投影表达式,因为它不是保留字.请参阅此处获取保留字列表:https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

                userId, on the other hand, does not require a projection expression because it is not a reserved word. See here for a list of reserved words: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

                但是,您不需要投影表达式.您可以简单地使用下面的代码.定义queryExpression.expressionAttributeNames"以创建状态属性值的替代名称.在这里,我使用了短语statusVal"作为替代.

                However, you don't need a projection expression. You can simply use the code below. Define "queryExpression.expressionAttributeNames" to create a substitute name for the status attribute value. Here, I used the phrase "statusVal" as a substitute.

                试试这个.(它对我有用)

                Try this. (It worked for me)

                let queryExpression = AWSDynamoDBQueryExpression()
                queryExpression.expressionAttributeNames = ["#statusVal":"status"] // Using statusVal because it is not reserved. You only need statusVal here because it is the only attribute that also happens to be an AWS reserved word.
                queryExpression.keyConditionExpression = "userId = :uId AND #statusVal = :sV"
                queryExpression.expressionAttributeValues = [
                     ":uId" : String(describing: userId),
                     ":sV" : "accept"]
                

                然后使用 AWSDynamoDBObjectMapper 执行操作!祝你好运!

                And then perform the operation using AWSDynamoDBObjectMapper! Good luck!

                这篇关于使用 Swift 3 在 DynamoDB 中保留关键字 ExpressionAttributeValues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用 AWS Cognito 开发人员身份从我的 ios 应用程序 下一篇:DynamoDB 列表类型

                相关文章

                最新文章

                <legend id='OtaH4'><style id='OtaH4'><dir id='OtaH4'><q id='OtaH4'></q></dir></style></legend>

                  <small id='OtaH4'></small><noframes id='OtaH4'>

                  <tfoot id='OtaH4'></tfoot>
                1. <i id='OtaH4'><tr id='OtaH4'><dt id='OtaH4'><q id='OtaH4'><span id='OtaH4'><b id='OtaH4'><form id='OtaH4'><ins id='OtaH4'></ins><ul id='OtaH4'></ul><sub id='OtaH4'></sub></form><legend id='OtaH4'></legend><bdo id='OtaH4'><pre id='OtaH4'><center id='OtaH4'></center></pre></bdo></b><th id='OtaH4'></th></span></q></dt></tr></i><div id='OtaH4'><tfoot id='OtaH4'></tfoot><dl id='OtaH4'><fieldset id='OtaH4'></fieldset></dl></div>
                  • <bdo id='OtaH4'></bdo><ul id='OtaH4'></ul>