db.collection.aggregate() (mongosh method) - Database Manual - MongoDB Docs
Use the db.collection.aggregate() method to calculate aggregate values for data in a collection or view, process documents, and return computed results.