accesspatterns.dev

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.

Playlists

These rows are real and already here. Running an operation against them downloads a DynamoDB-compatible engine, about 850 KB, and executes it in this tab.

Try an example

SET changes one attribute and leaves the rest of the META item untouched.

pk(pk)
sk(sk)
name
owner
title
seconds
PLAYLIST#chill
METAS
ChillS
adaS
PLAYLIST#chill
TRACK#001S
WeightlessS
485N
PLAYLIST#chill
TRACK#002S
An EndingS
252N
PLAYLIST#chill
TRACK#003S
Avril 14thS
120N
PLAYLIST#focus
METAS
FocusS
linusS
PLAYLIST#focus
TRACK#001S
SubstrataS
360N
PLAYLIST#focus
TRACK#002S
Music for 18 MusiciansS
3360N
PLAYLIST#focus
TRACK#003S
Spiegel im SpiegelS
540N
PLAYLIST#focus
TRACK#004S
MetamorphosisS
600N
PLAYLIST#focus
TRACK#005S
GlassworksS
380N
PLAYLIST#energy
METAS
EnergyS
graceS
PLAYLIST#energy
TRACK#001S
Lose YourselfS
326N
PLAYLIST#energy
TRACK#002S
BangarangS
215N
PLAYLIST#energy
TRACK#003S
TitaniumS
245N
PLAYLIST#energy
TRACK#004S
LevelsS
340N
PLAYLIST#energy
TRACK#005S
One More TimeS
320N
PLAYLIST#sleep
METAS
SleepS
adaS
PLAYLIST#sleep
TRACK#001S
SleepS
480N
PLAYLIST#sleep
TRACK#002S
We Move LightlyS
300N
PLAYLIST#sleep
TRACK#003S
SamanS
510N
PLAYLIST#sleep
TRACK#004S
Nuvole BiancheS
360N
PLAYLIST#commute
METAS
CommuteS
samS
PLAYLIST#commute
TRACK#001S
RoygbivS
180N
PLAYLIST#commute
TRACK#002S
TeardropS
330N
PLAYLIST#commute
TRACK#003S
Midnight CityS
244N
PLAYLIST#commute
TRACK#004S
Open Eye SignalS
460N

Run an operation to see the raw engine response.

table Playlistskeys pk / skitems 26