async updateOne(req, res) {
        try {
            // 
            const { id } = req.params;
            const schema = Joi.object().keys({
                title: Joi.string().required(),
                album: Joi.string(),
                url: Joi.string().required(),
                rating: Joi.number()
                    .integer()
                    .min(0)
                    .max(5)
                    .optional(),
                genre: Joi.string().required()
            });
            const { value, error } = Joi.validate(req.body, schema);
            if (error && error.details) {
                return res.status(400).json(error);
            } 

            const song = await Song.findByIdAndUpdate({ _id: id }, value, {new: true});
            
            if (!song) {
                return res.status(404).json({ err: `could not find song with id:${id}` });
            }
            return res.json({ song, success: `song updated successfully` });
        } catch (err) {
            console.error(err);
            return res.status(500).send(err);
        }
    }
// Method for getting one song from collection
Method for getting one song from collection
Method for getting one song from collection
async updateOne(req, res) {
        try {
            const { id } = req.params;
            const schema = Joi.object().keys({
                title: Joi.string().required(),
                album: Joi.string(),
                url: Joi.string().required(),
                rating: Joi.number()
                    .integer()
                    .min(0)
                    .max(5)
                    .optional(),
                genre: Joi.string().required()
            });
            const { value, error } = Joi.validate(req.body, schema);
            if (error && error.details) {
                return res.status(400).json(error);
            } 
            const song = await Song.findByIdAndUpdate({ _id: id }, value, {new: true});
            if (!song) {
                return res.status(404).json({ err: `could not find song with id:${id}` });
            }
            return res.json({ song, success: `song updated successfully` });
        } catch (err) {
            console.error(err);
            return res.status(500).send(err);
        }
    }
async updateOne ( req , res ) { try { const { id } = req . params ; const schema = Joi . object ( ) . keys ( { title : Joi . string ( ) . required ( ) , album : Joi . string ( ) , url : Joi . string ( ) . required ( ) , rating : Joi . number ( ) . integer ( ) . min ( 0 ) . max ( 5 ) . optional ( ) , genre : Joi . string ( ) . required ( ) } ) ; const { value , error } = Joi . validate ( req . body , schema ) ; if ( error && error . details ) { return res . status ( 400 ) . json ( error ) ; } const song = await Song . findByIdAndUpdate ( { _id : id } , value , { new : true } ) ; if ( ! song ) { return res . status ( 404 ) . json ( { err : ` ${ id } ` } ) ; } return res . json ( { song , success : ` ` } ) ; } catch ( err ) { console . error ( err ) ; return res . status ( 500 ) . send ( err ) ; } }
Method for getting one song from collection
Method for getting one song from collection
// 