-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
When creating an aggregation pipeline using Collection.aggregate, the result is a lazy object that won't run the aggregation pipeline until iteration has started. This is fine for pipelines where users expect a result to be returned, but for pipelines using a write stage (e.g. $merge or $out), this behaviour is problematic as there is no expectations for users to work with the return value of Collection.aggregate.
In my case, it took me several attempts to figure out why my aggregation pipeline wasn't run and I had to resort to calling Collection.aggregate(...).to_a to ensure the pipeline was created. This could be avoided by checking the last pipeline stage and disabling lazy execution if it is a write stage.
- has to be done after
-
MONGOID-4465 Create fluid aggregation API
- Closed