mongodb/mongo-ruby-driver — pull request #286 by estolfo (2013-10-21 17:17:23+00:00)
Title: Ruby 669 aggregate out

This pull request provides support for the new $out aggregation pipeline operator. It is new in version 2.6 of the server.

The $out pipeline operator allows you to specify the name of a collection to which the result of the aggregation will be written.

The result of the aggregation returned to the user will be the raw result document from the server if $out is used.

There is an additional check on the read preference used with the aggregation. The only replica set member that can be used with $out is the primary. This is because the result set is written to a collection. If a read preference other than primary is specified, the aggregation will be rerouted to the primary and a warning will be displayed saying:

Database command 'aggregate' rerouted to primary node