I try find one item by name, then update table and return updated result, but return didn't work. My code:
class addSongsToArtist {
constructor(artistName) {
Artist.findOne({
name: artistName
}).exec((err, data) => {
if (err) console.log(err);
data.name = 'updated name'
data.save();
return data // * not work
});
}
}
Into exec method I see data with correct result, and into mongo console result saved. But return not works. I tried save changes into external variable and return result in Promise, but it not work too. Why it not works?