summaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-03-16 11:22:42 +0100
committerGitHub <noreply@github.com>2021-03-16 11:22:42 +0100
commitb950072a3109d2c13881611a3950baa191caf097 (patch)
treeccfc5c2c26c56a496d0f34b3f4db0965c713e7bb /src/db.rs
parent48a9ac895b6e8b01622810ec4bf2f3a423426ca3 (diff)
parent6350610ef5f7d73680853d39898094f2bf15febb (diff)
Merge pull request #11 from gico-net/feat/add-repositories
Add CRUD for repository
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/db.rs b/src/db.rs
new file mode 100644
index 0000000..5367288
--- /dev/null
+++ b/src/db.rs
@@ -0,0 +1,9 @@
+use crate::errors::AppError;
+use deadpool_postgres::{Client, Pool, PoolError};
+
+/// Return a valid `Client` to make SQL queries
+pub async fn get_client(pool: Pool) -> Result<Client, AppError> {
+ pool.get()
+ .await
+ .map_err(|err: PoolError| AppError::from(err))
+}