Compare commits
1 Commits
cf5a38a376
...
dcf4993f68
| Author | SHA1 | Date | |
|---|---|---|---|
| dcf4993f68 |
@@ -45,6 +45,13 @@ pub async fn get_by_path(db: &DatabaseConnection, file_path: &str) -> DbResult<O
|
||||
.await?)
|
||||
}
|
||||
|
||||
pub async fn get_by_mbid(db: &DatabaseConnection, mbid: &str) -> DbResult<Vec<Track>> {
|
||||
Ok(Tracks::find()
|
||||
.filter(track::Column::MusicbrainzId.eq(mbid))
|
||||
.all(db)
|
||||
.await?)
|
||||
}
|
||||
|
||||
pub async fn list(db: &DatabaseConnection, limit: u64, offset: u64) -> DbResult<Vec<Track>> {
|
||||
Ok(Tracks::find()
|
||||
.order_by_asc(track::Column::Artist)
|
||||
|
||||
@@ -81,6 +81,18 @@ pub async fn update_mbid(
|
||||
Ok(active.update(db).await?)
|
||||
}
|
||||
|
||||
pub async fn update_track_id(
|
||||
db: &DatabaseConnection,
|
||||
id: i32,
|
||||
track_id: i32,
|
||||
) -> DbResult<WantedItem> {
|
||||
let existing = get_by_id(db, id).await?;
|
||||
let mut active: ActiveModel = existing.into();
|
||||
active.track_id = Set(Some(track_id));
|
||||
active.updated_at = Set(Utc::now().naive_utc());
|
||||
Ok(active.update(db).await?)
|
||||
}
|
||||
|
||||
pub async fn find_by_mbid(
|
||||
db: &DatabaseConnection,
|
||||
musicbrainz_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user