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, +}