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:
@@ -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)=>{
|
||||
|
||||
Reference in New Issue
Block a user