Problem Description
aggregate() can take either an object with a single stage or an array with multiple stages. This should be true both for the aggregate() method of a collection as well as for the aggregate() method of Explainable. However, it's not true for the latter and the error message is confusing.
Given the error, this might be an issue in the driver.
Steps to Reproduce
Run db.users.explain().aggregate({$match: {email: /@gmail.com/)}}
Expected Results
The explain plan for that one-stage pipeline.
Actual Results
MongoError: Unrecognized pipeline stage name: 'explain'