How to update an item in Dynamodb of type String Set (SS)?

前端 未结 3 1118
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-14 00:04

I have created a attribute of type String Set. When I create the Item and assign an attribute of type SS everything works. But when I try to update this attribute, the data type

3条回答
  •  庸人自扰
    2021-02-14 00:23

    As of September 2015, there is a createSet function in the DocumentClient that you can use for this.

    UPDATE - added example

    I've modified your example code to use this function:

    qw = new AWS.DynamoDB.DocumentClient();
    
    var params = {
      TableName : "myTable",
      Key: {
        "id": somekey
      },
      UpdateExpression: "set ssvar= :arrp",
      ExpressionAttributeValues: {
         ":arrp": qw.createSet([ "test", "test2" ])
      }
    };
    
    qw.update (etc.)
    

提交回复
热议问题