const { id: artistId } = req.params;
const albums = await Album.find({artist: artist._id});
if (!albums?.length) {
return res.status(404).send({error: 'Album or artist not found!'});
}
const albumsIds = albums.map(album => album._id);
const allTracks = await Track.find({ album: { $in: albumsIds } });
if (!allTracks?.length) {
return res.status(404).send({error: 'Tracks not found!'});
}
const tracksIds = allTracks .map(track=> track._id);
await TrackHistory.deleteMany({ track: { $in: tracksIds } });
await Track.deleteMany({ album: { $in: albumsIds } });
await Album.deleteMany({artist: artistId});
await Artist.deleteOne({ _id: artistId});
res.send('Delete successful!');
class Hamburger {
static SMALL = 'small';
static TOPPING_CHEESE = 'cheese';
// ...
.link {
posititon: relative;
}
.link::before {
content: "";
positioan: absolute;
top: -10px;
left: 0;
width: 100%;
height: 2px;
background-color: red;
opacity: 0;
transform: translate-y(-10px);
transition: 0.3s all ease;
}
.link:hover::before {
opacity: 1;
transform: translate-y(0);
}