Struct database::media::InsertableMedia
source · pub struct InsertableMedia {
pub library_id: i64,
pub name: String,
pub description: Option<String>,
pub rating: Option<f64>,
pub year: Option<i64>,
pub added: String,
pub poster: Option<i64>,
pub backdrop: Option<i64>,
pub media_type: MediaType,
}
Expand description
Fields§
§library_id: i64
§name: String
§description: Option<String>
§rating: Option<f64>
§year: Option<i64>
§added: String
§poster: Option<i64>
§backdrop: Option<i64>
§media_type: MediaType
Implementations§
source§impl InsertableMedia
impl InsertableMedia
sourcepub async fn insert(
&self,
conn: &mut Transaction<'_>
) -> Result<i64, DatabaseError>
pub async fn insert(
&self,
conn: &mut Transaction<'_>
) -> Result<i64, DatabaseError>
Method used to insert a new media object. Caller can optionally specify a media id if they wish to reuse a media object.
sourcepub async fn insert_with_id(
&self,
conn: &mut Transaction<'_>,
id: i64
) -> Result<i64, DatabaseError>
pub async fn insert_with_id(
&self,
conn: &mut Transaction<'_>,
id: i64
) -> Result<i64, DatabaseError>
Method used to insert a new media object with a specific id.
Arguments
conn
- mutable reference to a sqlx transaction.id
- Unused ID to use for this media object.
sourcepub async fn insert_blind(
&self,
conn: &mut Transaction<'_>
) -> Result<i64, DatabaseError>
pub async fn insert_blind(
&self,
conn: &mut Transaction<'_>
) -> Result<i64, DatabaseError>
Method blindly inserts self
into the database without checking whether a similar entry exists.
This is especially useful for tv shows as they usually have similar metadata with key differences
which are not indexed in the database.
sourcepub async fn lazy_insert(
&self,
tx: &mut Transaction<'_>
) -> Result<i64, DatabaseError>
pub async fn lazy_insert(
&self,
tx: &mut Transaction<'_>
) -> Result<i64, DatabaseError>
Lazily inserts the media object passed in with the following behavior.
If the media id exists in the database and has one child, the media id is reused and the media object passed in is re-inserted. If the media object has more than one child, we create a new media object and recouple. FIXME: How will this behave with cross-mediatype rematches??
Returns a tuple of the id and whether the media object has been in place modified
Trait Implementations§
source§impl Clone for InsertableMedia
impl Clone for InsertableMedia
source§fn clone(&self) -> InsertableMedia
fn clone(&self) -> InsertableMedia
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more