mongodb - update or replace the mongoose nested array object -
i have timesheet schema results below , want replace single data array object new set of values in mongoose. either want remove existing object , push new set of values or update old object new values.please suggest me proper way achieve this. struggled lot this, because new mongoose , mongodb. in advance
{ "_id": objectid("53f1fb3401ea96440d62646b"), "user_id": "andrew", "type": "solutions", "timesheets": [{ "weekstartdate": isodate("2014-08-18t00:00:00z"), "weekenddate": isodate("2014-08-22t00:00:00z"), "_id": objectid("53f1fb3401ea96440d62646c"), "data": [{ "date": isodate("2014-08-18t00:00:00z"), "_id": objectid("53f1fb3401ea96440d62646d"), "record": [{ "_id": objectid("53f1fb3401ea96440d626470"), "desc": "", "cellid": "0:0", "custname": "coach", "custid": "2", "timespend": "04:00", "categoryname": "billing", "categoryid": "1" }, { "_id": objectid("53f1fb3401ea96440d62646f"), "desc": "description", "cellid": "0:1", "custname": "", "custid": "", "timespend": "05:00", "categoryname": "solution", "categoryid": "4" }, { "_id": objectid("53f1fb3401ea96440d62646e"), "desc": "description", "cellid": "0:2", "custname": "", "custid": "", "timespend": "06:00", "categoryname": "gtm", "categoryid": "3" }], "savedflag": false, "submitflag": false }, { "date": isodate("2014-08-19t00:00:00z"), "_id": objectid("53f1fb4e01ea96440d626471"), "record": [{ "_id": objectid("53f1fb4e01ea96440d626474"), "desc": "", "cellid": "1:0", "custname": "morgan", "custid": "3", "timespend": "04:00", "categoryname": "rfp", "categoryid": "2" }, { "_id": objectid("53f1fb4e01ea96440d626473"), "desc": "", "cellid": "1:1", "custname": "morgan", "custid": "3", "timespend": "05:00", "categoryname": "rfp", "categoryid": "2" }, { "_id": objectid("53f1fb4e01ea96440d626472"), "desc": "", "cellid": "1:2", "custname": "citi", "custid": "1", "timespend": "04:00", "categoryname": "sales", "categoryid": "0" }], "savedflag": false, "submitflag": false }], "savedflag": true, "submitflag": false }], "__v": 0
} >
Comments
Post a Comment