{"size": 1381, "ext": "js", "max_stars_repo_path": "controllers/mongoose.controller.js", "max_stars_repo_name": "mohammadabufarweh/exam301-backend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "controllers/mongoose.controller.js", "max_issues_repo_name": "mohammadabufarweh/exam301-backend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "controllers/mongoose.controller.js", "max_forks_repo_name": "mohammadabufarweh/exam301-backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.2280701754, "max_line_length": 60, "alphanum_fraction": 0.5626357712}
const userModel =require('../models/mongoose.model')

const makeData=(req,response)=>{
    const {strDrink,strDrinkThumb}=req.body
    const slug =strDrink.toLowerCase().split(' ').join('-');
    const newUserModel= new userModel({
        strDrink:strDrink,
        slug:slug,
        strDrinkThumb:strDrinkThumb
    })
    newUserModel.sava();
    response.json(newUserModel)

}

const getData =(req,response)=>{
    userModel.find({},(error,userData)=>{
        if (error){
            response.send(error)
        }else{
            response.send(userData)
        }
    })
}
const deleteData =async (req,response)=>{
    const slug=req.prams.slug;
    userModel.remove({slug:slug},(error,userData)=>{
        if (error){
            response.send(error)
        }else{
            userModel.find({},(error,userData)=>{
                response.send(userData)

            })
        }
    })
 
}


const updateData= async (req,response)=>{
    const strDrink=req.body;
    const slug=req.prams.slug;
    userModel.find({slug:slug},(error,userData)=>{
        if (error){
            response.send(error)
        }else{
            userData[0].strDrink=strDrink
            userData[0].save();
            userData.find({},(error,userData)=>{
                response.send(userData)
            })
        }
    })
    
}
module.exports={makeData,getData,deleteData,updateData}