From a587459a1817c0fc57b46df3f9c69567e1e775b7 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 12 Dec 2023 18:20:56 +0000 Subject: refactor: separate model and controller --- src/db/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/db/mod.rs (limited to 'src/db/mod.rs') diff --git a/src/db/mod.rs b/src/db/mod.rs new file mode 100644 index 0000000..f010bf8 --- /dev/null +++ b/src/db/mod.rs @@ -0,0 +1,18 @@ +mod users; + +use sqlx::{Pool, Postgres}; + +use self::users::Users; + +#[derive(Clone)] +pub struct Database(Pool); + +impl Database { + pub fn new(pool: Pool) -> Self { + Self(pool) + } + + pub fn users(&self) -> Users { + Users::new(self.0.clone()) + } +} -- cgit