mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-03-24 15:08:12 +00:00
Fixed issue with arrays not being saved
This commit is contained in:
@@ -30,12 +30,15 @@ router.post('/api/brew', (req, res, next)=>{
|
||||
|
||||
//Update
|
||||
router.put('/api/brew/:editId', mw.loadBrew, (req, res, next)=>{
|
||||
console.log(req.account);
|
||||
const brew = req.body || {};
|
||||
if(req.account){
|
||||
brew.authors = _.uniq(_.concat(brew.authors, req.account.username));
|
||||
}
|
||||
console.log(brew);
|
||||
BrewData.update(req.params.editId, brew)
|
||||
.then((brew) => {
|
||||
console.log(brew.toJSON());
|
||||
return res.json(brew.toJSON());
|
||||
})
|
||||
.catch(next);
|
||||
|
||||
@@ -65,6 +65,9 @@ const BrewData = {
|
||||
delete newBrew.shareId;
|
||||
delete newBrew.editId;
|
||||
brew = _.merge(brew, newBrew, { updatedAt : Date.now() });
|
||||
|
||||
brew.markModified('authors');
|
||||
brew.markModified('systems');
|
||||
return brew.save();
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user