title: How to I return a json object along with totals in mongoose?
body: <p>I have a database of exercises in a workout tracker, and when I do a find(), the result is this:</p>
  
  <pre><code>[
  {
  "_id": "5e9dacbb6512969974bd5b2d",
  "day": "2020-04-10T14:07:55.905Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Bicep Curl",
  "duration": 20,
  "weight": 100,
  "reps": 10,
  "sets": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b2e",
  "day": "2020-04-11T14:07:55.916Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Lateral Pull",
  "duration": 20,
  "weight": 300,
  "reps": 10,
  "sets": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b2f",
  "day": "2020-04-12T14:07:55.916Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Push Press",
  "duration": 25,
  "weight": 185,
  "reps": 8,
  "sets": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b30",
  "day": "2020-04-13T14:07:55.916Z",
  "exercises": [
  {
  "type": "cardio",
  "name": "Running",
  "duration": 25,
  "distance": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b31",
  "day": "2020-04-14T14:07:55.916Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Bench Press",
  "duration": 20,
  "weight": 285,
  "reps": 10,
  "sets": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b32",
  "day": "2020-04-15T14:07:55.916Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Bench Press",
  "duration": 20,
  "weight": 300,
  "reps": 10,
  "sets": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b33",
  "day": "2020-04-16T14:07:55.916Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Quad Press",
  "duration": 30,
  "weight": 300,
  "reps": 10,
  "sets": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b34",
  "day": "2020-04-17T14:07:55.916Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Bench Press",
  "duration": 20,
  "weight": 300,
  "reps": 10,
  "sets": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b35",
  "day": "2020-04-18T14:07:55.916Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Military Press",
  "duration": 20,
  "weight": 300,
  "reps": 10,
  "sets": 4
  }
  ]
  },
  {
  "_id": "5e9dacbb6512969974bd5b36",
  "day": "2020-04-19T14:07:55.916Z",
  "exercises": [
  {
  "type": "resistance",
  "name": "Bench",
  "duration": 30,
  "distance": 2
  }
  ]
  }
  ]
  </code></pre>
  
  <p>Then I need to get total sums of statistics from each exercise, so I used mongoose aggregate to give me this data:</p>
  
  <pre><code>[
  {
  "_id": null,
  "totalDuration": 230,
  "totalWeight": 2070,
  "totalSets": 32,
  "totalReps": 78,
  "totalDistance": 6
  }
  ]
  </code></pre>
  
  <p>I want to combine these two results in one GET request, ideally doing something similar to a push where I just push the totals at the end of the first JSON object. How do I achieve this?</p>