Add docs for fetch_all, example for postgres transactions (#1255)

* reference fetch_all() in query macros

* add example for using transactions in postgres
This commit is contained in:
Rafael Epplée
2021-08-17 01:33:42 +02:00
committed by GitHub
parent 71388a7ef2
commit e77219f7c7
7 changed files with 83 additions and 0 deletions

View File

@@ -36,6 +36,7 @@
/// | Zero or One | `.fetch_optional(...).await`| `sqlx::Result<Option<{adhoc struct}>>` | Extra rows are ignored. |
/// | Exactly One | `.fetch_one(...).await` | `sqlx::Result<{adhoc struct}>` | Errors if no rows were returned. Extra rows are ignored. Aggregate queries, use this. |
/// | At Least One | `.fetch(...)` | `impl Stream<Item = sqlx::Result<{adhoc struct}>>` | Call `.try_next().await` to get each row result. |
/// | Multiple | `.fetch_all(...)` | `sqlx::Result<Vec<{adhoc struct}>>` | |
///
/// \* All methods accept one of `&mut {connection type}`, `&mut Transaction` or `&Pool`.
/// † Only callable if the query returns no columns; otherwise it's assumed the query *may* return at least one row.
@@ -459,6 +460,7 @@ macro_rules! query_file_unchecked (
/// | Zero or One | `.fetch_optional(...).await`| `sqlx::Result<Option<T>>` | Extra rows are ignored. |
/// | Exactly One | `.fetch_one(...).await` | `sqlx::Result<T>` | Errors if no rows were returned. Extra rows are ignored. Aggregate queries, use this. |
/// | At Least One | `.fetch(...)` | `impl Stream<Item = sqlx::Result<T>>` | Call `.try_next().await` to get each row result. |
/// | Multiple | `.fetch_all(...)` | `sqlx::Result<Vec<T>>` | |
///
/// \* All methods accept one of `&mut {connection type}`, `&mut Transaction` or `&Pool`.
/// (`.execute()` is omitted as this macro requires at least one column to be returned.)