
Once you are done your can export the result to your language of choice. If you are going to put together an aggregation pipeline for the first time I recommend using MongoDb Compass, which comes with a UI for building pipelines that makes it easy to get familiar with the language for creating aggregation steps. How to put together your first aggregation pipeline This result can then be stored to disk using the $out or $merge aggregation stages, depending on whether you want to replace the resulting collection or add to it. You then get a result which may be a few hundred rows long, but contains data put together from thousands or millions of records. While you can define your aggregation pipelines in any language (Node.js, Python, Java, etc.) once they are sent to MongoDb they get executed using C++ inside the MongoDb context, so your thousands/millions of records are processed in an optimized manner and do not need to go anywhere. Store the result into disk, so it is essentially written once and read many times easily.Have a way of building the aggregate information INSIDE your database, so that your millions of records do not have to be moved around to get the result.This is a slow and time-consuming process which should never be executed in real-time every time a user requests the information (they’ll be waiting a long time, and you’ll be doing a lot of processing unnecessarily). You see people like to consume information in the form of summary tables and charts, but getting this information ready for them often requires trawling through thousands or millions of records. Use MongoDb aggregation pipelines to create dashboards in a way that is easy to load.
