Atomic Primitives and Opt-In Timestamps
examples/atomic-primitives/main.go
is a runnable example that exercises the three behaviours this release adds or
fixes, in one item, against a real DynamoDB Local endpoint — no mocks:
- Managed timestamps are opt-in. The model tags
created_atandupdated_at; itsOwnedAtcolumn is atime.Timethat is deliberately not tagged, and is stored exactly as the application sets it. created_atis written once. The example creates the item, reads it back, modifies it and writes it again; the creation time survives the second write whileupdated_atadvances.incrementandadvance. Three increments return1,2,3, and anadvancethat proposes an earlier value is a reported no-op that leaves the floor where it was.
Every claim is asserted in the example, so it fails rather than prints when the runtime drifts:
timestamps: created_at_kept=true updated_at_advanced=true owned_at_kept=true
increment: sequence=[1 2 3]
advance: first=true backward_no_advance=true held=1767225600
OK: TableTheory opt-in timestamps, atomic increment and monotonic advance against DynamoDB Local
Run it
make docker-up
DYNAMODB_ENDPOINT=http://localhost:8000 go run ./examples/atomic-primitives
The example is registered in the local examples harness, so
make examples-local runs it too and asserts the exact lines above against the
checked-in DynamoDB Local profile.
Related
- Atomic Primitives — the primitive contract
- Lifecycle Timestamps — the opt-in timestamp contract
- Migrating to v7 — the breaking change this example relies on