MongoDB C++ Driver
mongocxx-3.7.0
|
Class representing a MongoDB change stream. More...
#include <change_stream.hpp>
Classes | |
class | iterator |
Class representing a MongoDB change stream iterator. More... | |
Public Member Functions | |
change_stream (change_stream &&other) noexcept | |
Move constructs a change_stream. | |
change_stream & | operator= (change_stream &&other) noexcept |
Move assigns a change_stream. | |
~change_stream () | |
Destroys a change_stream. | |
iterator | begin () const |
A change_stream::iterator points to the beginning of any available notifications. More... | |
iterator | end () const |
A change_stream::iterator indicating stream exhaustion, meaning that no notifications are available from the stream. More... | |
bsoncxx::stdx::optional< bsoncxx::document::view > | get_resume_token () const |
Returns a resume token for this change stream. More... | |
Class representing a MongoDB change stream.
iterator mongocxx::change_stream::begin | ( | ) | const |
A change_stream::iterator points to the beginning of any available notifications.
Each call to begin() advances to the next available notification. The state of all iterators is tracked by the change_stream itself, so advancing one iterator advances all iterators.
change_stream::begin() and the increment operators are blocking operations. They will not return until a notification is available, the max_await_time (from the options::change_stream) milliseconds have elapsed, or a server error is encountered.
When change_stream.begin() == change_stream.end(), no notifications are available. Each call to change_stream.begin() checks again for newly-available notifications.
Throws | mongocxx::query_exception if the query failed. |
iterator mongocxx::change_stream::end | ( | ) | const |
A change_stream::iterator indicating stream exhaustion, meaning that no notifications are available from the stream.
bsoncxx::stdx::optional<bsoncxx::document::view> mongocxx::change_stream::get_resume_token | ( | ) | const |
Returns a resume token for this change stream.
If the change stream has not been iterated, and either resume_after or start_after was specified in the options to this change stream, the specified value will be returned by this method. If neither resume_after or start_after was set on the options for this change stream, and it has not been iterated, this method will return no token.
Once this change stream has been iterated, this method will return the resume token of the most recently returned document in the stream, or a postBatchResumeToken if the current batch of documents has been exhausted.
The returned document::view is valid for the lifetime of the stream and its data may be updated if the change stream is iterated after this function. The value may be copied to extend its lifetime or preserve the current resume token.