toCollection

Aggregates documents according to the specified aggregation pipeline, which must end with an $out or $merge stage. This method is the preferred alternative to cursor, because this method does what is explicitly requested without executing implicit operations.

See also

Throws

if the pipeline does not end with an $out or $merge stage