On Sat, 10 Mar 2018 09:41:11 GMT, Sönke Ludwig wrote:

To work around the issue, the aggregate expression can be embedded into an array literal:

db[collection].aggregate( 
    [["$group":["_id":"$"~variable]]]
)

The documentation
https://vibed.org/api/vibe.db.mongo.collection/MongoCollection.aggregate
presents two templates.

Bson aggregate(ARGS...) (
  ARGS pipeline
);

MongoCursor!R aggregate(R, S) (
  S[] pipeline,
  AggregateOptions options
);

and yet says further down the page it says,

Returns

An array of documents returned by the pipeline

This seems to contradict the second template.

Presumably the original code that wouldn't compile used the first template, and this fix that does compile would seem to use the second which returns a cursor, not a Bson list of documents, correct?

More generally than my example and its workaround fix, is it true that use of the first template is limited by the 16MB hard limit on query result size in mongodb, so the returned Bson list must be inside this limit?

Whereas presumably use of the second template may produce (via the returned cursor) a sequence of documents whose summed size is not limited to 16MB, as long as each individual document is inside that limit, correct?