Storage layout

View Source

One 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:

entitypkskgsi1
site settingsSITESETTINGS
userUSER#idUSERUSERS / email
postPOST#idPOSTPOSTS#status / sort_at#id
post by slugSLUG#slugPOST
post revisionPOST#idREV#at
post in tag / by authorTAG#slug, AUTHOR#idPOST#sort_at#id
widget / version / instance stateWIDGET#slug / WSTATE#slug#instanceWIDGET / VER#n / STATEWIDGETS
studio session / transcriptSTUDIO / STUDIO#sidSESSION#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.