How to put a new key-value pair into a map in DynamoDB? (java)

前端 未结 2 578
没有蜡笔的小新
没有蜡笔的小新 2020-12-28 16:55

I have a DynamoDB attribute whose value is a map from a Number to a String. I am trying to put in a new key-value pair. From what I\'ve read, this seems to be possible, but

2条回答
  •  长发绾君心
    2020-12-28 17:26

    With the following arguments to UpdateItem, you can condition adding a map entry at #number when map.#number does not exist in the map already:

    UpdateExpression = "SET map.#number = :string"
    ExpressionAttributeNames = { "#number" : "1" }
    ExpressionAttributeValues = { ":string" : "the string to store in the map at key value 1" }
    ConditionExpression = "attribute_not_exists(map.#number)"
    

提交回复
热议问题