UpdateItem edits in place
UpdateItem changes named attributes and can increment a counter atomically.
Why
UpdateItem changes the attributes you name and leaves everything else alone. SET assigns a value; ADD increments a number atomically on the server, so two concurrent increments can never lose each other.
Rename the playlist, then count a play twice and watch plays climb. Note name uses an ExpressionAttributeNames placeholder because some attribute names are reserved words.
UpdateItem edits in place. ADD gives you atomic counters with no read-modify-write race.
Try it. Then change it.
Predict what each request will do. Run it, inspect the response, then change a value in the workbench and try again.
SET changes one attribute and leaves the rest of the META item untouched.
ADD increments a number atomically, server-side, creating it from zero. Run it again and it climbs.
Built on this
- URL Shortener - Where does this short link go?
- Stock Counter - Can we fulfil this order?
- Trending Counter - What’s getting attention?
SET changes one attribute and leaves the rest of the META item untouched.
Choose an access pattern above, or build your own request. See what comes back and what it costs.