Function checks if a technology is save in a mongo DB and if it is saved, the technology object is returned, if it is not saved, a new technology object is to be created and then returned. but when the function is called, the return value is null
function saveTechnology(technology) {
//check if technology is already in database
Technology.findOne({name: technology}).then(foundTechnology => {
if(foundTechnology){
return foundTechnology
}else{
new Technology({
name: technology
}).save((err, newTechnology) => {
if(err){
}else{
return newTechnology
}
});
}
});
}