LoginSignup
0

More than 5 years have passed since last update.

How to add number to Number Set in DynamoDB

Last updated at Posted at 2017-01-31

AWS.DynamoDB.DocumentClient does not provide a way to add number to Number Set.
Need to use lower api Class: AWS.DynamoDB — AWS SDK for JavaScript.

I've tried few times and figured out the sytax of ADD operaion which is not desctibed in UpdateItem reference. Just put ADD, column name and value.

See Modifying Items and Attributes with Update Expressions - Amazon DynamoDB for ADD syntax.

Following code appends given numbers without making dupes.

dynamodb.updateItem({
  "TableName" : "mytable",
  "Key" : {
    "Id": {"S": uuid},
  },
  "UpdateExpression" : "ADD setname :valuesToAdd",
  "ExpressionAttributeValues" : {
    ": valuesToAdd" : { "NS": ["440"] }
  },
  ReturnValues:"UPDATED_NEW"
});

Refs

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0