mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 08:12:39 +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();
|
brew = saved?.toObject();
|
||||||
} else {
|
} else {
|
||||||
// if the brew does have a stub id, update it using the stub id as the key.
|
// 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;
|
if(!saved) return;
|
||||||
// Call and wait for afterSave to complete
|
// Call and wait for afterSave to complete
|
||||||
const after = await afterSave();
|
const after = await afterSave();
|
||||||
if(!after) return;
|
if(!after) return;
|
||||||
|
|
||||||
res.status(200).send(brew);
|
res.status(200).send(saved);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteGoogleBrew = async (account, id, editId, res)=>{
|
const deleteGoogleBrew = async (account, id, editId, res)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user