tide-sqlx
Tide middleware for SQLx pooled connections & transactions.
A middleware which holds a pool of postgres connections, and automatically hands each tide::Request a connection, which may transparently be either a postgres transaction, or a direct pooled connection.
By default, transactions are used for all http methods other than GET and HEAD.
When using this, use the PostgresRequestExt
extenstion trait to get the connection.
Example
async
Why you may want to use this
Postgres transactions are very useful because they allow easy, assured rollback if something goes wrong. However, transactions incur extra runtime cost which is too expensive to justify for READ operations that do not need this behavior.
In order to allow transactions to be used seamlessly in endpoints, this middleware manages a transaction if one is deemed desirable.
License
Licensed under the BlueOak Model License 1.0.0 — Contributions via DCO 1.1