Finished realtor dao
This commit is contained in:
parent
e1ae542ffd
commit
63a9334da0
|
@ -0,0 +1 @@
|
|||
SELECT * FROM realtor WHERE id = $1;
|
|
@ -0,0 +1 @@
|
|||
SELECT * FROM realtor WHERE shortcode = $1;
|
|
@ -0,0 +1,5 @@
|
|||
INSERT INTO realtor (
|
||||
id, name, bio, phone_number, email, profile_picture_url, show_projects, shortcode, remax_agent_id, time_created, last_updated
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $10
|
||||
) RETURNING *;
|
|
@ -0,0 +1,11 @@
|
|||
UPDATE realtor SET
|
||||
name = $2,
|
||||
bio = $3,
|
||||
phone_number = $4,
|
||||
email = $5,
|
||||
profile_picture_url = $6,
|
||||
show_projects = $7,
|
||||
remax_agent_id = $8,
|
||||
last_updated = $9
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
|
@ -0,0 +1,5 @@
|
|||
pub mod click;
|
||||
pub mod project;
|
||||
pub mod property;
|
||||
pub mod realtor;
|
||||
pub mod trackable;
|
|
@ -0,0 +1,20 @@
|
|||
use realtor_lp_types::domain::realtor::Realtor;
|
||||
use sqlx::PgPool;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
pub async fn get_realtor_with_id(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> {
|
||||
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> {
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue