MCPcopy Create free account
hub / github.com/Moosync/Moosync / remove_songs

Method remove_songs

src-tauri/database/src/database.rs:296–341  ·  view source on GitHub ↗
(&self, ids: Vec<String>)

Source from the content-addressed store, hash-verified

294 // TODO: Remove album
295 #[tracing::instrument(level = "debug", skip(self))]
296 pub fn remove_songs(&self, ids: Vec<String>) -> Result<()> {
297 trace!("Removing song");
298 self.pool
299 .get()
300 .unwrap()
301 .transaction::<(), MoosyncError, _>(|conn| {
302 for id in ids {
303 // First delete analytics data to avoid foreign key constraint violations
304 delete(QueryDsl::filter(
305 analytics,
306 schema::analytics::song_id.eq(id.clone()),
307 ))
308 .execute(conn)?;
309
310 // Then delete bridge references
311 delete(QueryDsl::filter(
312 album_bridge,
313 schema::album_bridge::song.eq(id.clone()),
314 ))
315 .execute(conn)?;
316 delete(QueryDsl::filter(
317 artist_bridge,
318 schema::artist_bridge::song.eq(id.clone()),
319 ))
320 .execute(conn)?;
321 delete(QueryDsl::filter(
322 genre_bridge,
323 schema::genre_bridge::song.eq(id.clone()),
324 ))
325 .execute(conn)?;
326 delete(QueryDsl::filter(
327 playlist_bridge,
328 schema::playlist_bridge::song.eq(id.clone()),
329 ))
330 .execute(conn)?;
331
332 // Finally delete the song itself
333 delete(QueryDsl::filter(allsongs, _id.eq(id.clone()))).execute(conn)?;
334 }
335 Ok(())
336 })?;
337
338 info!("Removed song");
339
340 Ok(())
341 }
342
343 #[tracing::instrument(level = "debug", skip(self, song))]
344 pub fn update_song(&self, song: QueryableSong) -> Result<()> {

Callers 2

test_remove_songsFunction · 0.80
remove_songMethod · 0.80

Calls 3

getMethod · 0.80
cloneMethod · 0.80
eqMethod · 0.45

Tested by 1

test_remove_songsFunction · 0.64