Method: Mongo::Collection#watch
- Defined in:
- lib/mongo/collection.rb
#watch(pipeline = [], options = {}) ⇒ ChangeStream
Note:
A change stream only allows ‘majority’ read concern.
Note:
This helper method is preferable to running a raw aggregation with a $changeStream stage, for the purpose of supporting resumability.
As of version 3.6 of the MongoDB server, a “$changeStream“ pipeline stage is supported in the aggregation framework. This stage allows users to request that notifications are sent for all changes to a particular collection.
653 654 655 656 657 |
# File 'lib/mongo/collection.rb', line 653 def watch(pipeline = [], = {}) = .dup [:cursor_type] = :tailable_await if [:max_await_time_ms] View::ChangeStream.new(View.new(self, {}, ), pipeline, nil, ) end |