Answers for "mongoose aggregate group by date"

1

mongoose aggregate group by date

yourModel.aggregate([
  { 
    $group: { 
      _id: { 
        $dateToString: { 
          format: "%Y-%m-%d", 
          date: "$date"
        } 
      }, 
      count: { 
        $sum: 1 
      } 
    } 
  },
  { 
    $sort: {
      _id: 1
    } 
  }
])
Posted by: Guest on April-06-2021

Code answers related to "mongoose aggregate group by date"

Code answers related to "Javascript"

Browse Popular Code Answers by Language