From 0335e3d255cb2c573d1be5364507ac95ba07956c Mon Sep 17 00:00:00 2001 From: Carter Bertolini Date: Fri, 1 Nov 2024 16:48:56 -0400 Subject: [PATCH] Created model --- src/models.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/models.rs b/src/models.rs index b96c8d2..fb96465 100644 --- a/src/models.rs +++ b/src/models.rs @@ -626,3 +626,24 @@ pub struct HistoryEntry { /// The id of the song that was listened to pub song_id: i32, } + +/// Model for a playlist +#[cfg_attr(feature = "ssr", derive(Queryable, Selectable, Insertable))] +#[cfg_attr(feature = "ssr", diesel(table_name = crate::schema::playlists))] +#[cfg_attr(feature = "ssr", diesel(check_for_backend(diesel::pg::Pg)))] +#[derive(Serialize, Deserialize)] +pub struct Playlist { + /// A unique id for the playlist + #[cfg_attr(feature = "ssr", diesel(deserialize_as = i32))] + pub id: Option, + /// The time the playlist was created + #[cfg_attr(feature = "ssr", diesel(deserialize_as = SystemTime))] + pub created_at: Option, + /// The time the playlist was last updated + #[cfg_attr(feature = "ssr", diesel(deserialize_as = SystemTime))] + pub updated_at: Option, + /// The id of the user who owns the playlist + pub owner_id: i32, + /// The name of the playlist + pub name: String, +}