Use db_type for HistoryEntry
This commit is contained in:
@ -1,23 +1,14 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use libretunes_macro::db_type;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use diesel::prelude::*;
|
||||
}
|
||||
}
|
||||
|
||||
/// 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)))]
|
||||
#[db_type(crate::schema::song_history)]
|
||||
#[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>,
|
||||
#[omit_new]
|
||||
pub id: i32,
|
||||
/// The id of the user who listened to the song
|
||||
pub user_id: i32,
|
||||
/// The date the song was listened to
|
||||
|
@ -16,6 +16,7 @@ pub use album::NewAlbum;
|
||||
pub use artist::Artist;
|
||||
pub use artist::NewArtist;
|
||||
pub use history_entry::HistoryEntry;
|
||||
pub use history_entry::NewHistoryEntry;
|
||||
pub use playlist::Playlist;
|
||||
pub use song::NewSong;
|
||||
pub use song::Song;
|
||||
|
Reference in New Issue
Block a user