From 66ce2a66787193f98f027c2bfaec9c9758352481 Mon Sep 17 00:00:00 2001 From: Franklin Date: Fri, 14 Apr 2023 16:39:12 -0400 Subject: [PATCH] Added count to domian --- src/domain/contact.rs | 1 - src/domain/count.rs | 8 ++++++++ src/domain/mod.rs | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/domain/count.rs diff --git a/src/domain/contact.rs b/src/domain/contact.rs index 27fb1d4..7af7d3a 100644 --- a/src/domain/contact.rs +++ b/src/domain/contact.rs @@ -2,7 +2,6 @@ use chrono::{DateTime, Utc}; use serde::{Serialize, Deserialize}; -/// A unit of measurement to define a page load #[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct Contact { pub id: i32, diff --git a/src/domain/count.rs b/src/domain/count.rs new file mode 100644 index 0000000..5448cef --- /dev/null +++ b/src/domain/count.rs @@ -0,0 +1,8 @@ +use serde::{Serialize, Deserialize}; + + +/// Used to retrieve count(*) from the database. The reason there's a need for this is sqlx::query_as macro requires a struct, not a primitive. +#[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub struct Count { + pub count: Option +} diff --git a/src/domain/mod.rs b/src/domain/mod.rs index 25db7dd..852de2c 100644 --- a/src/domain/mod.rs +++ b/src/domain/mod.rs @@ -11,4 +11,5 @@ pub mod project_type; pub mod unit; pub mod unit_type; pub mod visit; -pub mod contact; \ No newline at end of file +pub mod contact; +pub mod count; \ No newline at end of file