diff options
| author | Nathan Perry <avaglir@gmail.com> | 2018-04-05 15:40:24 -0400 |
|---|---|---|
| committer | Nathan Perry <avaglir@gmail.com> | 2018-04-05 15:40:24 -0400 |
| commit | 82aefce4f7c5f24730fb5da22ee426988ae4301a (patch) | |
| tree | 27368baaff68d27a5357e877c28099058ce7f4d0 | |
| parent | 5b025763c42f9ab43d0cd67c52298b7d6f43e036 (diff) | |
reorganize models and add ImageMeme
| -rw-r--r-- | src/db/models.rs | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/src/db/models.rs b/src/db/models.rs index c06c41e..85cba2a 100644 --- a/src/db/models.rs +++ b/src/db/models.rs @@ -1,17 +1,33 @@ use super::schema::*;
use chrono::naive::NaiveDateTime;
-#[derive(Insertable, Queryable, Identifiable, AsChangeset, Debug, Associations)]
-#[belongs_to(Audio)]
-#[belongs_to(Image)]
-#[belongs_to(TextMeme)]
-#[belongs_to(ImageMeme)]
-#[belongs_to(TextMeme)]
-#[table_name="metadata"]
-pub struct Metadata {
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug)]
+#[table_name="text_memes"]
+pub struct TextMeme {
pub id: i32,
- pub created: NaiveDateTime,
- pub created_by: i64,
+ pub title: String,
+ pub content: String,
+ pub image_id: Option<i32>,
+ pub audio_id: Option<i32>,
+ pub metadata_id: i32,
+}
+
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug)]
+#[table_name="image_memes"]
+pub struct ImageMeme {
+ pub id: i32,
+ pub title: String,
+ pub image_id: i32,
+ pub metadata_id: i32,
+}
+
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug)]
+#[table_name="audio_memes"]
+pub struct AudioMeme {
+ pub id: i32,
+ pub title: String,
+ pub audio_id: i32,
+ pub metadata_id: i32,
}
#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug, Associations)]
@@ -34,24 +50,17 @@ pub struct Image { pub metadata_id: i32,
}
-#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug)]
-#[table_name="audio_memes"]
-pub struct AudioMeme {
- pub id: i32,
- pub title: String,
- pub audio_id: i32,
- pub metadata_id: i32,
-}
-
-#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug)]
-#[table_name="text_memes"]
-pub struct TextMeme {
+#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug, Associations)]
+#[belongs_to(Audio)]
+#[belongs_to(Image)]
+#[belongs_to(TextMeme)]
+#[belongs_to(ImageMeme)]
+#[belongs_to(TextMeme)]
+#[table_name="metadata"]
+pub struct Metadata {
pub id: i32,
- pub title: String,
- pub content: String,
- pub image_id: Option<i32>,
- pub audio_id: Option<i32>,
- pub metadata_id: i32,
+ pub created: NaiveDateTime,
+ pub created_by: i64,
}
#[derive(Insertable, Queryable, Identifiable, PartialEq, AsChangeset, Debug, Associations)]
|
