From 62def56a41f7ee69d49f4139e3c1c6ebdf064771 Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Sun, 19 May 2024 15:43:58 -0400 Subject: [PATCH] Add model for history entry --- src/models.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/models.rs b/src/models.rs index 442713e..3076937 100644 --- a/src/models.rs +++ b/src/models.rs @@ -292,3 +292,20 @@ impl Song { Ok(my_artists) } } + +/// Model for a history entry +#[cfg_attr(feature = "ssr", derive(Queryable, Selectable, Insertable))] +#[cfg_attr(feature = "ssr", diesel(table_name = crate::schema::song_history))] +#[cfg_attr(feature = "ssr", diesel(check_for_backend(diesel::pg::Pg)))] +#[derive(Serialize, Deserialize)] +pub struct HistoryEntry { + /// A unique id for the history entry + #[cfg_attr(feature = "ssr", diesel(deserialize_as = i32))] + pub id: Option, + /// The id of the user who listened to the song + pub user_id: i32, + /// The date the song was listened to + pub date: SystemTime, + /// The id of the song that was listened to + pub song_id: i32, +}