Expand description
The database, as the request pipeline and the schema-cache loader use it.
Two drivers answer to this interface. sqlx is the one the server and the Lambda adapter run on. A Cloudflare Worker has no sqlx, and speaks the PostgreSQL wire protocol over a socket of its own (issue #50).
The interface is small, and it is shaped by what the callers need rather than by what a driver offers:
- Rows are decoded to JSON by the driver itself, with no row type in between. An intermediate value per column would be an allocation and a copy on every value of every paged or embedded read.
- It is used generically, never as
dyn, so the native build calls sqlx exactly as it did before the interface existed. - Every statement runs inside a transaction (
Db::begin). That is where a request’s role and claims are set, and nothing runs outside it.
On wasm32 the futures are not Send, because nothing in a Worker is; see
MaybeSend.
Structs§
- DbError
- A failure reported by a driver.
- RawRows
- What
Tx::fetch_rawreads from a result. - SqlxTx
- A transaction on a pooled connection, which goes back to the pool when this is committed or dropped.
Traits§
- Db
- A database a request can open a transaction on.
- Maybe
Send Sendnatively, nothing at all on wasm32.- Maybe
Sync Syncnatively, nothing at all on wasm32. SeeMaybeSend.- Tx
- An open transaction. Dropped without
Tx::commit, it rolls back.
Type Aliases§
- BoxFuture
- A boxed future,
SendwhereMaybeSendis. For recursion, which anasync fncannot do without a box. - Fetched
Then - What
Tx::fetch_json_thenreturns: the rows, and the second statement’s rows, by position.