summaryrefslogtreecommitdiff
path: root/dichroism/src/image_repo.rs
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-10-20 09:50:08 -0400
committerAdam T. Carpenter <atc@53hor.net>2020-10-20 09:50:08 -0400
commit76a782599b4ecc4ecb9b0ce7acc6420ed9e1ec8e (patch)
treedfc108120f067880b708a64ef6567879f4bb3284 /dichroism/src/image_repo.rs
parentd3a28fde46bb06f084c74904fa8849b40e5f8c87 (diff)
downloadtheglassyladies-76a782599b4ecc4ecb9b0ce7acc6420ed9e1ec8e.tar.xz
theglassyladies-76a782599b4ecc4ecb9b0ce7acc6420ed9e1ec8e.zip
back to basics -- working on the most-required functionality first, like handlers
Diffstat (limited to 'dichroism/src/image_repo.rs')
-rw-r--r--dichroism/src/image_repo.rs57
1 files changed, 0 insertions, 57 deletions
diff --git a/dichroism/src/image_repo.rs b/dichroism/src/image_repo.rs
deleted file mode 100644
index e0f420b..0000000
--- a/dichroism/src/image_repo.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-use super::models::{NewProductImg, ProductImg};
-use diesel::prelude::*;
-use diesel::result::Error;
-
-type DBConn = SqliteConnection;
-
-pub fn read_images(conn: &DBConn) -> Result<Vec<ProductImg>, Error> {
- use crate::schema::images::dsl::*;
- let results = images.load::<ProductImg>(conn)?;
- Ok(results)
-}
-
-fn read_images_by_path(conn: &DBConn, path: &str) -> Result<Vec<ProductImg>, Error> {
- use crate::schema::images::dsl::*;
- let results = images.filter(path.eq(path)).load::<ProductImg>(conn)?;
- Ok(results)
-}
-
-pub fn read_image_by_path(conn: &DBConn, path: &str) -> Result<Option<ProductImg>, Error> {
- use crate::schema::images::dsl::*;
- let results = images
- .filter(path.eq(path))
- .limit(1)
- .load::<ProductImg>(conn)?;
- Ok(results.first().cloned())
-}
-
-pub fn read_image_by_id(conn: &DBConn, id: i32) -> Result<Option<ProductImg>, Error> {
- use crate::schema::images::dsl::*;
- let results = images.filter(id.eq(id)).limit(1).load::<ProductImg>(conn)?;
- Ok(results.first().cloned())
-}
-
-pub fn create_image(conn: &DBConn, new_image: NewProductImg) -> Result<Option<ProductImg>, Error> {
- use super::schema::images;
- diesel::insert_into(images::table)
- .values(&new_image)
- .execute(conn)?;
- read_image_by_path(conn, &new_image.path)
-}
-
-pub fn update_image() {
- todo!()
-}
-
-pub fn delete_image() {
- todo!()
-}
-
-#[cfg(test)]
-mod tests {
-
- #[test]
- fn test() -> std::result::Result<(), Box<dyn std::error::Error>> {
- Ok(())
- }
-}