0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

switch updateOne to findOneAndUpdate and return the saved instead of the brew passed in

This commit is contained in:
Charlie Humphreys
2022-12-05 21:00:44 -06:00
parent fec1766e26
commit 99019be152

View File

@@ -247,14 +247,16 @@ const updateBrew = async (req, res)=>{
brew = saved?.toObject();
} else {
// if the brew does have a stub id, update it using the stub id as the key.
saved = await HomebrewModel.updateOne({ _id: brew._id }, brew).catch(saveError);
saved = await HomebrewModel.findOneAndUpdate({ _id: brew._id }, brew, {
returnOriginal : false
}).catch(saveError);
}
if(!saved) return;
// Call and wait for afterSave to complete
const after = await afterSave();
if(!after) return;
res.status(200).send(brew);
res.status(200).send(saved);
};
const deleteGoogleBrew = async (account, id, editId, res)=>{