thanks for the space. I'm currently working in a project where I have to evaluate some conditions. The point is that I have been using this structure during the project, but in this case, the first condition is evaluated and does what it is meant to do, but not the second. Here I attach the piece of Code. Thanks a lot!
if (influencerUserId.isCompany === true) {
recommendedPeople = await Recommended.create({
recommendedEmail, recommendedFirstName, recommendedLastName, offerId: theOffer, recommendedPhoneNumber,
recommendedLinkedin, howFoundCandidate,
candidateInfo: {
candidateEducation, language, candidateLocation, experiences, similiarExp, ownDescription, motivations, whyFits,
availability, moneyExpec, currentSituation, otherAspects
},
moneyForRec: companyUserMoneyPerRec
});
recommendedTimes = await Offers.findByIdAndUpdate(theOffer, {
$push: { recommendedTimes: recommendedPeople }
}, { new: true })
historicRecommendations = recommendedPeople
let companyUser = await CompanyUser.findByIdAndUpdate(influencerUserId.companyUser, { $inc: { 'companyUserPunctuation': 5 } }, { new: true })
const updatedUser = await InfluencerUser.findByIdAndUpdate(influencerUserId, { $push: { recommendedPeople: recommendedPeople._id, historicRecommendations: historicRecommendations._id}, companyUser }, { new: true })
res.status(200).json({ updatedUser })
} else if(influencerUserId.isCompany === false) {
recommendedPeople = await Recommended.create({
recommendedEmail, recommendedFirstName, recommendedLastName, offerId: theOffer,
whyRec, recommendedPhoneNumber, moneyForRec:influencerUserMoneyperRec
});
recommendedTimes = await Offers.findByIdAndUpdate(theOffer, {
$push: { recommendedTimes: recommendedPeople }
}, { new: true })
historicRecommendations = recommendedPeople
const updatedUser = await InfluencerUser.findByIdAndUpdate(influencerUserId, { $push: { recommendedPeople: recommendedPeople._id, historicRecommendations: historicRecommendations._id, recommendedTimes: recommendedTimes._id} , $inc: {'influencerUserPunctuation': 5 } }, { new: true })
res.status(200).json({ updatedUser})
}
Aucun commentaire:
Enregistrer un commentaire