Create Tag tables and Add Tag endpoint

This commit is contained in:
Cameron Cordes
2021-09-03 19:34:38 -04:00
parent 2d6db6d059
commit 8939ffbaf5
7 changed files with 155 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
use crate::database::schema::{favorites, users};
use crate::database::schema::{favorites, tagged_photo, tags, users};
use serde::Serialize;
#[derive(Insertable)]
@@ -29,3 +29,29 @@ pub struct Favorite {
pub userid: i32,
pub path: String,
}
#[derive(Serialize, Queryable, Clone, Debug)]
pub struct Tag {
pub id: i32,
pub name: String,
}
#[derive(Insertable, Clone, Debug)]
#[table_name = "tags"]
pub struct InsertTag {
pub name: String,
}
#[derive(Insertable, Clone, Debug)]
#[table_name = "tagged_photo"]
pub struct InsertTaggedPhoto {
pub tag_id: i32,
pub photo_name: String,
}
#[derive(Queryable, Clone, Debug)]
pub struct TaggedPhoto {
pub id: i32,
pub photo_name: String,
pub tag_id: i32,
}