|
|
@@ -53,6 +53,7 @@ module.exports = {
|
|
|
id: id of recipe,
|
|
|
name: name of recipe,
|
|
|
price: price of recipe,
|
|
|
+ category: String
|
|
|
ingredients: [{
|
|
|
ingredient: id of ingredient,
|
|
|
quantity: quantity of ingredient in recipe
|
|
|
@@ -66,12 +67,14 @@ module.exports = {
|
|
|
merchant: res.locals.merchant._id,
|
|
|
name: recipe.name,
|
|
|
price: recipe.price,
|
|
|
+ category: recipe.category,
|
|
|
date: new Date(),
|
|
|
ingredients: recipe.ingredients
|
|
|
}).save().catch(()=>{});
|
|
|
|
|
|
recipe.name = req.body.name;
|
|
|
recipe.price = req.body.price;
|
|
|
+ recipe.category = req.body.category;
|
|
|
recipe.ingredients = req.body.ingredients;
|
|
|
|
|
|
return recipe.save();
|
|
|
@@ -80,9 +83,7 @@ module.exports = {
|
|
|
res.json(recipe);
|
|
|
})
|
|
|
.catch((err)=>{
|
|
|
- if(typeof(err) === "string"){
|
|
|
- return res.json(err);
|
|
|
- }
|
|
|
+ if(typeof(err) === "string") return res.json(err);
|
|
|
if(err.name === "ValidationError"){
|
|
|
return res.json(err.errors[Object.keys(err.errors)[0]].properties.message);
|
|
|
}
|