Add model for history entry

This commit is contained in:
Ethan Girouard 2024-05-19 15:43:58 -04:00
parent 0c64865cd9
commit 62def56a41
Signed by: eta357
GPG Key ID: 7BCDC36DFD11C146

View File

@ -292,3 +292,20 @@ impl Song {
Ok(my_artists) 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<i32>,
/// 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,
}