mongodb - Meteor element in array of a array -
basically wanted push data within array of array i.e publicholidays outer array , holidaylist inner array. mongodb schema looking right now.
"publicholidays" : [ { "location" :"pune" "year" : 2016 "holidaylist"[ { "holidaydate" :"2016-11-09", "holidayname":"diwali" } ] } ] expecting below schema,wanted push data in holidaylist. "publicholidays" : [ { "location" :"pune" "year" : 2016 "holidaylist"[ { "holidaydate" :"2016-11-09", "holidayname":"diwali" } { "holidaydate" :"2016-1-09", "holidayname":"padwa" } { "holidaydate" :"2016-12-10", "holidayname":"holi" } ] } ]
solved issue:
//add holidays in exist location 'companysettings.updatepublicholidays'(formvalues){ companysettings.update( { '_id': formvalues.uniqueid, 'publicholidays' : {$elemmatch : {'location': formvalues.holidayslocation,'year': formvalues.holidayyear} } }, { $push : {'publicholidays.$.holidaylist': { 'holidaydate' : formvalues.leavedate , 'holidayname' : formvalues.holidayname } } } ); },
Comments
Post a Comment