У меня есть данные db Монго, подобные этим.
{
"_id": "1234",
"programId": ObjectId("1234"),
"userId": "23",
"courses": [
{
"stateName": "Stage 1",
"duration": "5",
"lag": "2",
"courseType": "3",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2018-12-01T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100,
},
{
"stateName": "2nd stage",
"duration": "60",
"lag": "60",
"courseType": "2",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-02-01T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "3rd Stage",
"duration": "5",
"lag": "2",
"courseType": "1",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-04-07T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "4th stage",
"duration": 1,
"lag": "10",
"courseType": "1",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-04-10T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "5th",
"duration": "1",
"lag": "0",
"courseType": "3",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-04-21T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "6th",
"duration": "5",
"lag": "5",
"courseType": "3",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-04-26T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "7th ",
"duration": 1,
"lag": "9",
"courseType": "3",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-05-02T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "8th",
"duration": "66",
"lag": 0,
"courseType": "3",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-07-16T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "9th",
"duration": "61",
"lag": 0,
"courseType": "1",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-09-15T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "10th",
"duration": "80",
"lag": 0,
"courseType": "3",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-12-04T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
},
{
"stateName": "11th",
"duration": "8",
"lag": 0,
"courseType": "3",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2019-12-12T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100
}
],
"userStatus": 1,
"modified": ISODate("2018-11-27T14:01:32.082+05:30"),
"created": ISODate("2018-11-27T14:01:32.082+05:30"),
"completionStatus": "F",
"currentState": {
"courseId": "116",
"courseProgress": 100
}
}
Я хочу удалить планируемыеStartDate, scheduleEndDate, courseProgress из массива курсов, за исключением первого индекса.
Я хочу получить такой результат
{
"_id": "1234",
"programId": ObjectId("1234"),
"userId": "23",
"courses": [
{
"stateName": "Stage 1",
"duration": "5",
"lag": "2",
"courseType": "3",
"scheduledStartDate": ISODate("2018-11-27T14:01:30.000+05:30"),
"scheduledEndDate": ISODate("2018-12-01T14:01:30.000+05:30"),
"transitionType": "onAssignment",
"courseProgress": 100,
},
{
"stateName": "2nd stage",
"duration": "60",
"lag": "60",
"courseType": "2",
"transitionType": "onAssignment",
},
{
"stateName": "3rd Stage",
"duration": "5",
"lag": "2",
"courseType": "1",
"transitionType": "onAssignment",
},
{
"stateName": "4th stage",
"duration": 1,
"lag": "10",
"courseType": "1",
"transitionType": "onAssignment",
},
{
"stateName": "5th",
"duration": "1",
"lag": "0",
"courseType": "3",
"transitionType": "onAssignment",
},
{
"stateName": "6th",
"duration": "5",
"lag": "5",
"courseType": "3",
"transitionType": "onAssignment",
},
{
"stateName": "7th ",
"duration": 1,
"lag": "9",
"courseType": "3",
"transitionType": "onAssignment",
},
{
"stateName": "8th",
"duration": "66",
"lag": 0,
"courseType": "3",
"transitionType": "onAssignment",
},
{
"stateName": "9th",
"duration": "61",
"lag": 0,
"courseType": "1",
"transitionType": "onAssignment",
},
{
"stateName": "10th",
"duration": "80",
"lag": 0,
"courseType": "3",
"transitionType": "onAssignment",
},
{
"stateName": "11th",
"duration": "8",
"lag": 0,
"courseType": "3",
"transitionType": "onAssignment",
}
],
"userStatus": 1,
"modified": ISODate("2018-11-27T14:01:32.082+05:30"),
"created": ISODate("2018-11-27T14:01:32.082+05:30"),
"completionStatus": "F",
"currentState": {
"courseId": "116",
"courseProgress": 100
}
}