Sitemap
Towards AWS

Where Cloud Experts, Heroes, Builders, and Developers share their stories, experiences, and solutions.

Member-only story

Increment Number Values In DynamoDB With The ADD Operator

4 min readApr 28, 2025

--

Press enter or click to view image in full size

Have you ever needed to increment a number value in DynamoDB but weren’t sure how to?

I’ve seen many users fetch the previous value of that counter just to be able to increment it.

This method, while it works, isn’t efficient. It is costing you an extra read each time you need to update the item’s value.

There is however a DynamoDB API method that will allow you to increment number counters without knowing what the previous value was.

Let’s take a look at this.

The ADD Operator

The ADD operator in DynamoDB allows you to update an item’s number value.

This is typically done in an update expression using the ADD operator in the UpdateExpression of your UpdateCommand.

Here’s a code example:

UpdateExpression: 'ADD #count :incr',
ExpressionAttributeNames: {
'#count': 'count',
},
ExpressionAttributeValues: {
':incr': 1,
},

The ADD operator is defined in the UpdateExpression.

--

--

Rainmaker @ Buildside. Buildside is a social network for founders building in public.

Towards AWS
Towards AWS

Published in Towards AWS

Where Cloud Experts, Heroes, Builders, and Developers share their stories, experiences, and solutions.