node.js - How to get and update a specific object inside an array with Mongoose? -
i'm having real trouble mongodb , mongoose queries. thing is, have menu schema: var menuschema = new schema({ userid: string, name: string, meals: [{ day: number, hour: number, minute: number, aliments: [{ name: string, amount: number, }], }], }); so i'd know how specific meal or aliment , how update them throught _id value, automatically generated when add them. thank much. david. i working meals, not aliments. i'm doing meals: menu.update({_id: request.params.menu_id, 'meals._id': request.params.meal_id}, {'meals.$.hour': request.body.hour)}, function(error, affected, raw) { response.send(error); }); and aliments: menu.update({_id: request.params.menu_id, 'meals.aliments._id': request.params.aliment_id}, {'meals.aliments.$': {name: request.body.name, amount: request.body.amount}}, function(error, affected, raw) { response.sen...