I have tried here but I'm not getting correct answer this code will update only one record but I have to update multiple records at a time with different ids and I supposed to pass different ids as an endpoint to an API.
async function bulkupdate(req,res){
var i;
let successCount =0;
let errorCount = 0;
var student = req.body;
var id = req.params.id;
const schema = {
name : {type : "string" , optional : false , max :"100"},
sem : {type : "number" , optional : false },
branch :{type : "string" , optional:false,max:"100"}
}
for(i=0;i<student.length;i++){
const v = new validator();
var result1 = await v.validate(student[i] , schema);
if(result1 === true){
var result = await models.Student.update(student[i],{where :{id:id}});
successCount++;
}else{
errorCount++
return res.send({result1,errorCount,successCount})
}
}
res.status(200).json({
successCount:successCount,
errorCount:errorCount,
});
}