Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a functioning code which creates a new JSON object based on my schema but I'd like to target the objects inside of the overall object. I'm not sure if this is possible... I'm stuck in between creating a new object but also updating an existing one

Here is my schema

year: { 
January: [
  {
    day: String,
    title: String,
    summary: String,
    description: String
  }
      ],

December: [
  {
    day: String,
    title: String,
    summary: String,
    description: String
  }
      ]
}
});

Here is my data in mongodb

{
  _id: "53ee9f0fc6aed109c6d33cfc"
  __v: 0
  -year: {
    December: [ ]
    November: [ ]
    October: [ ]
    September: [ ]
    August: [ ]
    July: [ ]
    -June: [
     -{
       day: "21"
       title: "ok"
       summary: "ok"
       description: "ok"
       _id: "53ee9f0fc6aed109c6d33cfd"
       }
         ]
    May: [ ]
    April: [ ]
    March: [ ]
    February: [ ]
    January: [ ]
    }
}

My problem is my logic as it currently is creates a whole new 'year' JSON object, where I would like to work with _id: "53ee9f0fc6aed109c6d33cfc" and add dates to each month.

Here is my current angular logic:

$scope.createEvent = function() {
  var cal = new CAL.API();


 var month = [{day:$scope.calDay, title: $scope.calTitle, summary: $scope.calSummary, 
        description: 'ok'}];
              cal.year = {};
              cal.year[$scope.calMonth] = month;
              cal.$save(function(result){
                $scope.calendar.push(result);
              });
            } 
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.