Storage layout
View SourceOne table, pk/sk, one index on gsi1pk/gsi1sk — a DynamoDB table with
a GSI, or a SQL table items(pk, sk, gsi1pk, gsi1sk, version, data) with the
item as JSON in data. Wraith.Store is a small key-value interface
(get/put/delete/query/transact/batch_get/update), so the adapters are thin and
the whole suite runs against each of them. The layout is in Wraith.Store.Keys:
| entity | pk | sk | gsi1 |
|---|---|---|---|
| site settings | SITE | SETTINGS | |
| user | USER#id | USER | USERS / email |
| post | POST#id | POST | POSTS#status / sort_at#id |
| post by slug | SLUG#slug | POST | |
| post revision | POST#id | REV#at | |
| post in tag / by author | TAG#slug, AUTHOR#id | POST#sort_at#id | |
| widget / version / instance state | WIDGET#slug / WSTATE#slug#instance | WIDGET / VER#n / STATE | WIDGETS |
| studio session / transcript | STUDIO / STUDIO#sid | SESSION#id / MSG#at#seq |
Uniqueness (slugs, emails) is a conditional put inside a transaction
(TransactWriteItems / INSERT … ON CONFLICT DO NOTHING with a row-count check);
Wraith.Store.update/3 is optimistic read-modify-write on version.