SERVER / DATABASE / TRANSACTIONS
Transactions
A Database transaction commits staged inserts through one provider-owned atomic boundary: a Dowe WAL frame, a PostgreSQL transaction, or a D1 atomic batch.
1 / TRANSACTION
Stage inserts, then publish one result
query result conn:db.tx opens the transaction. Every nested insert is validated before the provider commit. commit value:room returns the selected inserted record after the atomic commit succeeds; rollback discards every staged insert and returns null.
handler seedClinicData
database db provider:"dowe" host:env.DOWE_HOST port:env.DOWE_PORT account:env.DOWE_USER secret:env.DOWE_PASSWORD name:"clinic"
query result conn:db.tx
query room conn:db.insert table:"rooms" value:{ name:"Room 1" status:"available" }
query doctor conn:db.insert table:"staff" value:{ name:"Ada" role:"doctor" }
commit value:room
return json:{ ok:true data:result }2 / GUARANTEES
One atomic boundary per provider
Guarantee | What it means |
|---|---|
No dataThere are no records to display | |
3 / SCOPE AND OPERATIONS
Use the same transaction source with every provider
Area | Boundary |
|---|---|
No dataThere are no records to display | |
4 / SAFETY
Handle retries and storage deliberately
Concern | Rule |
|---|---|
No dataThere are no records to display | |