summaryrefslogtreecommitdiff
path: root/dichroism/src/photo_repo.rs
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-10-22 17:44:38 -0400
committerAdam T. Carpenter <atc@53hor.net>2020-10-22 17:44:38 -0400
commit99dabd3f2f81ffcf0b6f2b59e13ebb4502b2ccac (patch)
tree15e19324332173405fc7544af2c17195d7b05ff1 /dichroism/src/photo_repo.rs
parent76a782599b4ecc4ecb9b0ce7acc6420ed9e1ec8e (diff)
downloadtheglassyladies-99dabd3f2f81ffcf0b6f2b59e13ebb4502b2ccac.tar.xz
theglassyladies-99dabd3f2f81ffcf0b6f2b59e13ebb4502b2ccac.zip
Added product migration, better organization of DTOs, Entities, and
Domain Models. Also made config loading/photo generation easier.
Diffstat (limited to 'dichroism/src/photo_repo.rs')
-rw-r--r--dichroism/src/photo_repo.rs41
1 files changed, 0 insertions, 41 deletions
diff --git a/dichroism/src/photo_repo.rs b/dichroism/src/photo_repo.rs
deleted file mode 100644
index 64390c8..0000000
--- a/dichroism/src/photo_repo.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-use super::models::*;
-use diesel::prelude::*;
-use diesel::result::Error;
-
-type DBConn = SqliteConnection;
-
-pub fn read_photos(conn: &DBConn) -> Result<Vec<Photo>, Error> {
- use crate::schema::photos::dsl::*;
- let results = photos.load::<Photo>(conn)?;
- Ok(results)
-}
-
-fn read_photos_by_path(conn: &DBConn, path: &str) -> Result<Vec<Photo>, Error> {
- use crate::schema::photos::dsl::*;
- let results = photos.filter(path.eq(path)).load::<Photo>(conn)?;
- Ok(results)
-}
-
-pub fn read_photo_by_path(conn: &DBConn, path: &str) -> Result<Option<Photo>, Error> {
- use crate::schema::photos::dsl::*;
- let results = photos.filter(path.eq(path)).limit(1).load::<Photo>(conn)?;
- Ok(results.first().cloned())
-}
-
-pub fn read_photo_by_id(conn: &DBConn, id: i32) -> Result<Option<Photo>, Error> {
- use crate::schema::photos::dsl::*;
- let results = photos.filter(id.eq(id)).limit(1).load::<Photo>(conn)?;
- Ok(results.first().cloned())
-}
-
-pub fn create_photo(conn: &DBConn, new_photo: NewPhoto) -> Result<Option<Photo>, Error> {
- use super::schema::photos;
- diesel::insert_into(photos::table)
- .values(&new_photo)
- .execute(conn)?;
- read_photo_by_path(conn, &new_photo.path)
-}
-
-pub fn update_photo() {
- todo!()
-}