Need to interpret a js query into an aggregate query, please

db.getCollection("token_collection").find().map(({
                tokenName,
                symbol,
                blockchain,
                vestingCategories,
              }) => {
    const dates = Object.entries(vestingCategories).reduce(
                  (acc, [categoryName, categoryData]) => {
                  const currentDate = new Date();

                    categoryData.byDates.forEach(({ created }) => {
                      const [day, month, year] = created
                        .split('/')
                        .map(Number);

                      const createdDateFormat = new Date(
                        year,
                        month,
                        day
                      );

                    if(createdDateFormat > currentDate) {
                      if (acc[createdDateFormat]) {
                        if (
                          !acc[createdDateFormat].categories.includes(
                            categoryName
                          )
                        ) {
                          acc[createdDateFormat].categories.push(
                            categoryName
                          );

                          acc[createdDateFormat].tokens +=
                            categoryData.aggregatedData.tokens;
                        }
                      } else {
                        acc[createdDateFormat] = {
                          tokens: categoryData.aggregatedData.tokens,
                          symbol,
                          tokenName,
                          categories: [categoryName],
                          date: createdDateFormat,
                          blockchain,
                        };
                      }
                      }
                    });

                    return acc;
                  },
                  {})

    return Object.values(dates);
}).toArray().flat().sort((a,b) => a.date - b.date)

Response: