Skip to content

Conversation

gagik
Copy link
Contributor

@gagik gagik commented Oct 14, 2024

Running aggregate() on a database with a non-array pipeline will now run a single stage aggregation. This will make it consistent with db.{collection}aggregate behavior so

db.aggregate({$listLocalSessions: {}}

is same as

db.aggregate([{$listLocalSessions: {}}])

@gagik gagik marked this pull request as ready for review October 14, 2024 13:53
@gagik gagik changed the title fix(shell-api): Running aggregate against a database with a single stage fails MONGOSH-1868 fix(shell-api): Add support for running aggregate database with a single stage MONGOSH-1868 Oct 16, 2024
@gagik gagik requested a review from addaleax October 17, 2024 08:13
Co-authored-by: Anna Henningsen <anna.henningsen@mongodb.com>
@gagik gagik merged commit af04244 into main Oct 18, 2024
63 of 69 checks passed
@gagik gagik deleted the gagik/aggregate-error branch October 18, 2024 08:25
@gagik
Copy link
Contributor Author

gagik commented Oct 18, 2024

Now that I'm looking into documentation more, perhaps it'd make sense to completely sync up with .aggregate() with how db.coll.aggregate works so it's less confusing; i.e. you can also specify aggregation stages asaggregate({ stage1: ... }, {stage2: ...}) (in which case options will not be possible). It seems more reasonable to have a 1:1 mapping between these two aggregate functions' params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants