I'm pretty new to javascript. I'm trying to graph orders by the dates that they were made. I want the graph to contain the days in-between those orders with orders for those dates as 0. How would I add these missing dates in javascript? In my backend, I'm using mongodb aggregate.
const dailyOrders = await Order.aggregate([
{
$group: {
_id: { $dateToString: { format: '%m-%d-%Y', date: '$createdAt' } },
orders: { $sum: 1 },
},
},
{ $sort: { _id: 1 } },
]);
Would I have to create a const and add it to createdAt? I would really appreciate any help or guidance on how to do this. Thank you!