lib/mongo/client.rb
# As of version 3.6 of the MongoDB server, a ``$changeStream`` pipeline stage is supported
# in the aggregation framework. As of version 4.0, this stage allows users to request that
# notifications are sent for all changes that occur in the client's cluster.
#
# @example Get change notifications for the client's cluster.
#  client.watch([{ '$match' => { operationType: { '$in' => ['insert', 'replace'] } } }])
#
# @param [ Array<Hash> ] pipeline Optional additional filter operators.
# @param [ Hash ] options The change stream options.
#
# @option options [ String ] :full_document Allowed values: 'default', 'updateLookup'.
#   Defaults to 'default'. When set to 'updateLookup', the change notification for partial
#   updates will include both a delta describing the changes to the document, as well as a copy
#   of the entire document that was changed from some time after the change occurred.
# @option options [ BSON::Document, Hash ] :resume_after Specifies the logical starting point
#   for the new change stream.
# @option options [ Integer ] :max_await_time_ms The maximum amount of time for the server to
#   wait on new documents to satisfy a change stream query.
# @option options [ Integer ] :batch_size The number of documents to return per batch.
# @option options [ BSON::Document, Hash ] :collation The collation to use.
# @option options [ Session ] :session The session to use.
# @option options [ BSON::Timestamp ] :start_at_operation_time Only return
#   changes that occurred at or after the specified timestamp. Any command run
#   against the server will return a cluster time that can be used here.
#   Only recognized by server versions 4.0+.
#
# @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.
#
# @return [ ChangeStream ] The change stream object.
#
# @since 2.6.0
As of version 3.6 of the MongoDB server, a ``$changeStream`` pipeline stage is supported
in the aggregation framework. As of version 4.0, this stage allows users to request that
notifications are sent for all changes that occur in the client's cluster.
As of version 3 . 6 of the MongoDB server a ` ` $changeStream ` ` pipeline stage is supported in the aggregation framework . As of version 4 . 0 this stage allows users to request that notifications are sent for all changes that occur in the client ' s cluster .
def watch(pipeline = [], options = {})
      return use(Database::ADMIN).watch(pipeline, options) unless database.name == Database::ADMIN
      Mongo::Collection::View::ChangeStream.new(
        Mongo::Collection::View.new(self["#{Database::COMMAND}.aggregate"]),
        pipeline,
        Mongo::Collection::View::ChangeStream::CLUSTER,
        options)
    end
def watch ( pipeline = [ ] , options = { } ) return use ( Database :: ADMIN ) . watch ( pipeline , options ) unless database . name == Database :: ADMIN Mongo :: Collection :: View :: ChangeStream . new ( Mongo :: Collection :: View . new ( self [ "#{Database::COMMAND}.aggregate" ] ) , pipeline , Mongo :: Collection :: View :: ChangeStream :: CLUSTER , options ) end
As of version 3.6 of the MongoDB server, a ``$changeStream`` pipeline stage is supported
in the aggregation framework.
As of version 3 . 6 of the MongoDB server a ` ` $changeStream ` ` pipeline stage is supported in the aggregation framework .
The change stream object.
The change stream object .
 ChangeStream 
pipeline
options
:start_at_operation_time Only return changes that occurred at or after the specified timestamp. Any command run against the server will return a cluster time that can be used here. Only recognized by server versions 4.0+.
: start_at_operation_time Only return changes that occurred at or after the specified timestamp . Any command run against the server will return a cluster time that can be used here . Only recognized by server versions 4 . 0 + .
options The change stream options.
options The change stream options .
example
Get change notifications for the client's cluster.
Get change notifications for the client ' s cluster .
note
A change stream only allows 'majority' read concern.
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.
This helper method is preferable to running a raw aggregation with a $changeStream stage for the purpose of supporting resumability .
since
None