【问题标题】:GoLang Updating DynamoDBGoLang 更新 DynamoDB
【发布时间】:2018-11-26 15:35:11
【问题描述】:

当我尝试使用下面的代码更新 DynamoDB 时,我得到 ValidationException: ExpressionAttributeValues contains invalid key: Syntax error; key: "approved"

我看不出它为什么无效

type TransactionUpdate struct {
    Approved bool `json:"approved"`
    Signer   int  `json:"signer"`
}

var TXkey Transaction
TXkey.TxID = sr.TxID
key, err := dynamodbattribute.MarshalMap(TXkey)

updateData, err := dynamodbattribute.MarshalMap(TransactionUpdate{
    Approved: true,
    Signer:   1,
})

updateString := "set approved=:a add signers :s"

input := &dynamodb.UpdateItemInput{
    Key:                       key,
    TableName:                 aws.String("Transactions"),
    UpdateExpression:          aws.String(updateString),
    ExpressionAttributeValues: updateData,
    ReturnValues:              aws.String("ALL_NEW"),
}

result, err := svc.UpdateItem(input)

dynamodbattribute.UnmarshalMap(result.Attributes, &tx)

非常感谢任何帮助

【问题讨论】:

    标签: go amazon-dynamodb


    【解决方案1】:

    您应该定义 :a:s 是什么:

    type TransactionUpdate struct {
        Approved bool `json:":a"`
        Signer   int  `json:":s"`
    }
    

    【讨论】:

      猜你喜欢
      • 2020-01-02
      • 2020-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-16
      • 2019-03-21
      • 2020-10-31
      相关资源
      最近更新 更多