'Is there any way to write below code smartly?
I am making api in the node js where in one api i call some data into one api. The problem is that this is slow, is there any way to make it more efficient?
constructor() {
this.userExperienceRepository = new UserExperienceRepository();
this.userEducationRepository = new UserEducationRepository();
this.userCertificationRepository = new UserCertificationRepository();
this.userExpertiseRepository = new UserExpertiseRepository();
this.userEquipmentRepository = new UserEquipmentRepository();
this.userRepository = new UserRepository();
}
async findAllByUserId(id) {
let profileDetail={};
profileDetail.user = await this.userRepository.findAllById(id);
profileDetail.user= deleteSecurityProperties(profileDetail.user);
profileDetail.experience = await this.userExperienceRepository.findAllByUserId(id);
profileDetail.education = await this.userEducationRepository.findAllByUserId(id);
profileDetail.certification = await this.userCertificationRepository.findAllByUserId(id);
profileDetail.expertise = await this.userExpertiseRepository.findAllByUserId(id);
profileDetail.equipment = await this.userEquipmentRepository.findAllByUserId(id);
return profileDetail;
}
}
function deleteSecurityProperties(user) {
delete user.password;
delete user.otp;
delete user.otpAttempts;
delete user.otpTimestamp;
return user;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
