mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Implement deletion
This commit is contained in:
parent
b25d7fe8ee
commit
751dcde351
8 changed files with 340 additions and 40 deletions
|
|
@ -879,6 +879,18 @@ impl Library {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_person(&self, person_id: &str) -> Result<()> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
diesel::delete(persons::table)
|
||||
.filter(persons::person_id.eq(person_id))
|
||||
.execute(connection)?;
|
||||
|
||||
self.changed();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_instrument(&self, name: TranslatedString) -> Result<Instrument> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
|
|
@ -921,6 +933,18 @@ impl Library {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_instrument(&self, instrument_id: &str) -> Result<()> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
diesel::delete(instruments::table)
|
||||
.filter(instruments::instrument_id.eq(instrument_id))
|
||||
.execute(connection)?;
|
||||
|
||||
self.changed();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_role(&self, name: TranslatedString) -> Result<Role> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
|
|
@ -962,6 +986,18 @@ impl Library {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_role(&self, role_id: &str) -> Result<()> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
diesel::delete(roles::table)
|
||||
.filter(roles::role_id.eq(role_id))
|
||||
.execute(connection)?;
|
||||
|
||||
self.changed();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_work(
|
||||
&self,
|
||||
name: TranslatedString,
|
||||
|
|
@ -1175,6 +1211,18 @@ impl Library {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_work(&self, work_id: &str) -> Result<()> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
diesel::delete(works::table)
|
||||
.filter(works::work_id.eq(work_id))
|
||||
.execute(connection)?;
|
||||
|
||||
self.changed();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_ensemble(&self, name: TranslatedString) -> Result<Ensemble> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
|
|
@ -1223,6 +1271,18 @@ impl Library {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_ensemble(&self, ensemble_id: &str) -> Result<()> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
diesel::delete(ensembles::table)
|
||||
.filter(ensembles::ensemble_id.eq(ensemble_id))
|
||||
.execute(connection)?;
|
||||
|
||||
self.changed();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_recording(
|
||||
&self,
|
||||
work: Work,
|
||||
|
|
@ -1345,6 +1405,18 @@ impl Library {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_recording(&self, recording_id: &str) -> Result<()> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
diesel::delete(recordings::table)
|
||||
.filter(recordings::recording_id.eq(recording_id))
|
||||
.execute(connection)?;
|
||||
|
||||
self.changed();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_album(
|
||||
&self,
|
||||
name: TranslatedString,
|
||||
|
|
@ -1427,6 +1499,18 @@ impl Library {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_album(&self, album_id: &str) -> Result<()> {
|
||||
let connection = &mut *self.imp().connection.get().unwrap().lock().unwrap();
|
||||
|
||||
diesel::delete(albums::table)
|
||||
.filter(albums::album_id.eq(album_id))
|
||||
.execute(connection)?;
|
||||
|
||||
self.changed();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Import a track into the music library.
|
||||
// TODO: Support mediums.
|
||||
pub fn import_track(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue