Ran cargo fmt & added trackable dao's
This commit is contained in:
parent
63a9334da0
commit
375a224d11
|
@ -0,0 +1 @@
|
||||||
|
SELECT * FROM trackable WHERE ip_address = $1;
|
|
@ -0,0 +1 @@
|
||||||
|
SELECT * FROM trackable WHERE id = $1;
|
|
@ -0,0 +1,5 @@
|
||||||
|
INSERT INTO trackable (
|
||||||
|
id, who_was, ip_address, browser_width, browser_height, user_agent, time_created
|
||||||
|
) VALUES(
|
||||||
|
$1, $2, $3, $4, $5, $6, $7
|
||||||
|
) RETURNING *;
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
pub mod click;
|
pub mod click;
|
||||||
|
#[allow(unused)]
|
||||||
pub mod project;
|
pub mod project;
|
||||||
|
#[allow(unused)]
|
||||||
pub mod property;
|
pub mod property;
|
||||||
|
#[allow(unused)]
|
||||||
pub mod realtor;
|
pub mod realtor;
|
||||||
|
#[allow(unused)]
|
||||||
pub mod trackable;
|
pub mod trackable;
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -2,19 +2,61 @@ use realtor_lp_types::domain::realtor::Realtor;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
|
||||||
pub async fn insert_realtor(conn: &PgPool, realtor: Realtor) -> Result<Realtor, sqlx::Error> {
|
pub async fn insert_realtor(conn: &PgPool, realtor: Realtor) -> Result<Realtor, sqlx::Error> {
|
||||||
sqlx::query_file_as!(Realtor, "sql/realtor/insert.sql", realtor.id, realtor.name, realtor.bio, realtor.phone_number, realtor.email, realtor.profile_picture_url, realtor.show_projects, realtor.shortcode, realtor.remax_agent_id, realtor.time_created).fetch_one(conn).await
|
sqlx::query_file_as!(
|
||||||
|
Realtor,
|
||||||
|
"sql/realtor/insert.sql",
|
||||||
|
realtor.id,
|
||||||
|
realtor.name,
|
||||||
|
realtor.bio,
|
||||||
|
realtor.phone_number,
|
||||||
|
realtor.email,
|
||||||
|
realtor.profile_picture_url,
|
||||||
|
realtor.show_projects,
|
||||||
|
realtor.shortcode,
|
||||||
|
realtor.remax_agent_id,
|
||||||
|
realtor.time_created
|
||||||
|
)
|
||||||
|
.fetch_one(conn)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_realtor_with_id(conn: &PgPool, realtor_id: &Uuid) -> Result<Option<Realtor>, sqlx::Error> {
|
pub async fn get_realtor_with_id(
|
||||||
sqlx::query_file_as!(Realtor, "sql/realtor/get_with_id.sql", realtor_id).fetch_optional(conn).await
|
conn: &PgPool,
|
||||||
|
realtor_id: &Uuid,
|
||||||
|
) -> Result<Option<Realtor>, sqlx::Error> {
|
||||||
|
sqlx::query_file_as!(Realtor, "sql/realtor/get_with_id.sql", realtor_id)
|
||||||
|
.fetch_optional(conn)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_realtor_with_shortcode(conn: &PgPool, realtor_shortcode: &String) -> Result<Option<Realtor>, sqlx::Error> {
|
pub async fn get_realtor_with_shortcode(
|
||||||
sqlx::query_file_as!(Realtor, "sql/realtor/get_with_shortcode.sql", realtor_shortcode).fetch_optional(conn).await
|
conn: &PgPool,
|
||||||
|
realtor_shortcode: &String,
|
||||||
|
) -> Result<Option<Realtor>, sqlx::Error> {
|
||||||
|
sqlx::query_file_as!(
|
||||||
|
Realtor,
|
||||||
|
"sql/realtor/get_with_shortcode.sql",
|
||||||
|
realtor_shortcode
|
||||||
|
)
|
||||||
|
.fetch_optional(conn)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_realtor(conn: &PgPool, realtor: Realtor) -> Result<Realtor, sqlx::Error> {
|
pub async fn update_realtor(conn: &PgPool, realtor: Realtor) -> Result<Realtor, sqlx::Error> {
|
||||||
sqlx::query_file_as!(Realtor, "sql/realtor/update.sql", realtor.id, realtor.name, realtor.bio, realtor.phone_number, realtor.email, realtor.profile_picture_url, realtor.show_projects, realtor.remax_agent_id, realtor.last_updated).fetch_one(conn).await
|
sqlx::query_file_as!(
|
||||||
|
Realtor,
|
||||||
|
"sql/realtor/update.sql",
|
||||||
|
realtor.id,
|
||||||
|
realtor.name,
|
||||||
|
realtor.bio,
|
||||||
|
realtor.phone_number,
|
||||||
|
realtor.email,
|
||||||
|
realtor.profile_picture_url,
|
||||||
|
realtor.show_projects,
|
||||||
|
realtor.remax_agent_id,
|
||||||
|
realtor.last_updated
|
||||||
|
)
|
||||||
|
.fetch_one(conn)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
use realtor_lp_types::domain::trackable::Trackable;
|
||||||
|
use sqlx::PgPool;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub async fn insert_trackable(
|
||||||
|
conn: &PgPool,
|
||||||
|
trackable: Trackable,
|
||||||
|
) -> Result<Trackable, sqlx::Error> {
|
||||||
|
sqlx::query_file_as!(
|
||||||
|
Trackable,
|
||||||
|
"sql/trackable/insert.sql",
|
||||||
|
trackable.id,
|
||||||
|
trackable.who_was,
|
||||||
|
trackable.ip_address,
|
||||||
|
trackable.browser_width,
|
||||||
|
trackable.browser_height,
|
||||||
|
trackable.user_agent,
|
||||||
|
trackable.time_created
|
||||||
|
)
|
||||||
|
.fetch_one(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_trackable_with_id(conn: &PgPool, trackable_id: &Uuid) -> Result<Option<Trackable>, sqlx::Error> {
|
||||||
|
sqlx::query_file_as!(Trackable, "sql/trackable/get_with_id.sql", trackable_id).fetch_optional(conn).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn fetch_trackables_with_ip_address(conn: &PgPool, ip_addr: String) -> Result<Vec<Trackable>, sqlx::Error> {
|
||||||
|
sqlx::query_file_as!(Trackable, "sql/trackable/fetch_all_with_ip.sql", ip_addr).fetch_all(conn).await
|
||||||
|
}
|
|
@ -4,5 +4,4 @@ mod services;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {}
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
Loading…
Reference in New Issue