constseries=awaitAnime.findOne(/*{$or: [*/{id:req.params.id.toLowerCase()}/*, {numericalId: req.params.id}]}*/);//TODO make sure all ID calls are lowercased
constseries=req.params.id.match(/^\d+$/)?awaitAnime.findOne({numericalId:req.params.id.toLowerCase()}):awaitAnime.findOne({id:req.params.id.toLowerCase()});//TODO make sure all ID calls are lowercased
};//TODO check that series can be submitted but not completed. consider making this not allowed, or figure out what to do about the fact that editing all the fields is a complete pain
if(!req.body.name){returnres.status(400).send("You did not provide a new name in your body.");}
if(!req.body.name.match(/^[\w_\-!?.:; ]+$/gm)||req.body.name.length>150){returnres.status(400).send("Your new name is too long or contains illegal characters.");}
try{
series.name=req.body.name.trim();
pushEdit("Updated name",req,series);
returnseries.save()
.then(()=>res.send("Name updated."))
.catch(()=>res.status(500).send("There was an error trying to update your name. Please try again."));
}catch{returnres.status(500).send("There was an error trying to update your name. Please try again.");}