Expand description
Episode struct encapsulates a media entry representing a episode
Fields§
§id: i64
§seasonid: i64
Season id foreign_key
episode: i64
episode number
media: Media
Regerence to a media object which represents this epsiode. We are essnetially aliasing and wrapping around Media transparently, behind the scene in the db episode inherits all fields from media.
Implementations§
source§impl Episode
impl Episode
pub async fn get_first_for_season(
conn: &mut Transaction<'_>,
season_id: i64
) -> Result<Self, DatabaseError>
pub async fn get_first_for_show(
conn: &mut Transaction<'_>,
tv_id: i64
) -> Result<Self, DatabaseError>
sourcepub async fn get_all_of_tv(
conn: &mut Transaction<'_>,
tv_show_id: i64
) -> Result<Vec<Self>, DatabaseError>
pub async fn get_all_of_tv(
conn: &mut Transaction<'_>,
tv_show_id: i64
) -> Result<Vec<Self>, DatabaseError>
Method returns all of the episodes belonging to a tv show.
Arguments
conn
- a mutable reference to a sqlx transaction.media
- reference to a media object which should be a tv show.
sourcepub async fn get_all_of_season(
conn: &mut Transaction<'_>,
season_id: i64
) -> Result<Vec<Episode>, DatabaseError>
pub async fn get_all_of_season(
conn: &mut Transaction<'_>,
season_id: i64
) -> Result<Vec<Episode>, DatabaseError>
Method returns all of the episodes belonging to a season.
Arguments
conn
- mutable reference to a sqlx transaction.media
- reference to a season object/entry.
sourcepub async fn get(
conn: &mut Transaction<'_>,
tv_id: i64,
season_num: i64,
ep_num: i64
) -> Result<Episode, DatabaseError>
pub async fn get(
conn: &mut Transaction<'_>,
tv_id: i64,
season_num: i64,
ep_num: i64
) -> Result<Episode, DatabaseError>
Method returns a episodes discriminated by episode number, season number and tv show id
Arguments
conn
- mutable reference to a sqlx transaction.id
- The id of a tv show we targetseason_num
- The season we are targettingep_num
- Episode we are targetting
pub async fn get_by_id(
conn: &mut Transaction<'_>,
episode_id: i64
) -> Result<Episode, DatabaseError>
pub async fn get_season_episode_by_id(
conn: &mut Transaction<'_>,
episode_id: i64
) -> Result<(i64, i64), DatabaseError>
pub async fn get_season_number(
&self,
conn: &mut Transaction<'_>
) -> Result<i64, DatabaseError>
sourcepub async fn get_next_episode(
&self,
conn: &mut Transaction<'_>
) -> Result<Episode, DatabaseError>
pub async fn get_next_episode(
&self,
conn: &mut Transaction<'_>
) -> Result<Episode, DatabaseError>
Function will query for the episode after the episode passed in.
sourcepub async fn get_prev_episode(
&self,
conn: &mut Transaction<'_>
) -> Result<Episode, DatabaseError>
pub async fn get_prev_episode(
&self,
conn: &mut Transaction<'_>
) -> Result<Episode, DatabaseError>
Function will query for the episode after the episode passed in.
sourcepub async fn get_last_watched_episode(
conn: &mut Transaction<'_>,
tvid: i64,
uid: UserID
) -> Result<Option<Episode>, DatabaseError>
pub async fn get_last_watched_episode(
conn: &mut Transaction<'_>,
tvid: i64,
uid: UserID
) -> Result<Option<Episode>, DatabaseError>
Function will query the last episode that was watched for a show.
pub async fn get_seasonid(
tx: &mut Transaction<'_>,
episodeid: i64
) -> Result<i64, DatabaseError>
sourcepub async fn delete(
conn: &mut Transaction<'_>,
episode_id: i64
) -> Result<usize, DatabaseError>
pub async fn delete(
conn: &mut Transaction<'_>,
episode_id: i64
) -> Result<usize, DatabaseError>
Method deletes a episode based on the tv show id, season number, and episode number
Arguments
id
- The id of a tv show we targetseason_num
- The season we are targettingep_num
- Episode we are targetting