DynamoDB UpdateItem in Node.js (AWS SDK v3)

UpdateItem changes specific attributes of one item (and creates the item if it doesn't exist), leaving everything else untouched. In AWS SDK v3 you send an UpdateItemCommand with an UpdateExpression.

Code

import {DynamoDBClient, UpdateItemCommand} from '@aws-sdk/client-dynamodb';

const client = new DynamoDBClient({region: 'us-east-1'});

const command = new UpdateItemCommand({
  TableName: 'Music',
  Key: {
    Artist: {S: 'Arturo Sandoval'},
    SongTitle: {S: 'Cubano Chant'}
  },
  UpdateExpression: 'SET #upd0 = :updValue0, #upd1 = :updValue1 ADD #upd2 :updValue2',
  ExpressionAttributeNames: {
    '#upd0': 'Genre',
    '#upd1': 'Year',
    '#upd2': 'Awards'
  },
  ExpressionAttributeValues: {
    ':updValue0': {S: 'Latin Jazz'},
    ':updValue1': {N: '1994'},
    ':updValue2': {N: '1'}
  },
  ReturnValues: 'ALL_NEW'
});

const response = await client.send(command);
console.log(response.Attributes); // the item after the update

Explanation

  • Key — the full primary key of the item to update.
  • UpdateExpression — one or more clauses:
    • SET assigns attributes (#upd0 = :updValue0 sets Genre; #upd1 = :updValue1 sets Year). Every attribute is aliased via ExpressionAttributeNames, so reserved words like Year are always safe.
    • ADD on a number does an atomic increment (ADD #upd2 :updValue2 adds 1 to Awards) — safe under concurrency, no read-modify-write race. REMOVE deletes an attribute; DELETE removes elements from a set.
  • ExpressionAttributeValues — the :placeholder → typed-value map.
  • ReturnValues"ALL_NEW" returns the full item after the update (also UPDATED_NEW, ALL_OLD, UPDATED_OLD, or NONE).
  • Upsert semanticsUpdateItem creates the item if the key doesn't exist. Add a ConditionExpression (e.g. attribute_exists(Artist)) to update-only.

Do it visually

The DynamoDB Expression Builder builds SET / ADD / REMOVE clauses with the name/value maps and copies runnable code.

To edit items in a GUI — change a field, review the generated UpdateExpression, copy the SDK v3 code — download DynoTable.

References

Last verified 2026-07-13 against the official AWS documentation linked above.

Work with DynamoDB without the Console

DynoTable is a fast desktop client for DynamoDB — browse tables, run SQL-style queries, and edit items locally.