Method: Mongo::Collection::View::Readable#aggregate
- Defined in:
- lib/mongo/collection/view/readable.rb
#aggregate(pipeline, options = {}) ⇒ Aggregation
Execute an aggregation on the collection view.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mongo/collection/view/readable.rb', line 61 def aggregate(pipeline, = {}) = @options.merge() unless Mongo. aggregation = Aggregation.new(self, pipeline, ) # Because the $merge and $out pipeline stages write documents to the # collection, it is necessary to clear the cache when they are performed. # # Opt to clear the entire cache rather than one namespace because # the $out and $merge stages do not have to write to the same namespace # on which the aggregation is performed. QueryCache.clear if aggregation.write? aggregation end |