MongoDB C++ Driver  mongocxx-3.6.2
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
change_stream.hpp
1 // Copyright 2018-present MongoDB Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <chrono>
18 
19 #include <bsoncxx/document/view_or_value.hpp>
20 #include <bsoncxx/string/view_or_value.hpp>
21 #include <bsoncxx/types.hpp>
22 #include <mongocxx/stdx.hpp>
23 
24 #include <mongocxx/config/prelude.hpp>
25 
26 namespace mongocxx {
27 MONGOCXX_INLINE_NAMESPACE_BEGIN
28 
29 class client;
30 class collection;
31 class database;
32 
33 namespace options {
34 
35 class MONGOCXX_API change_stream {
36  public:
37  change_stream();
38 
58 
65  const bsoncxx::stdx::optional<bsoncxx::string::view_or_value>& full_document() const;
66 
77  change_stream& batch_size(std::int32_t batch_size);
78 
85  const stdx::optional<std::int32_t>& batch_size() const;
86 
103 
110  const stdx::optional<bsoncxx::document::view_or_value>& resume_after() const;
111 
130 
137  const stdx::optional<bsoncxx::document::view_or_value>& start_after() const;
138 
150 
157  const stdx::optional<bsoncxx::document::view_or_value>& collation() const;
158 
170  change_stream& max_await_time(std::chrono::milliseconds max_time);
171 
178  const stdx::optional<std::chrono::milliseconds>& max_await_time() const;
179 
195 
196  private:
197  friend class ::mongocxx::client;
198  friend class ::mongocxx::collection;
199  friend class ::mongocxx::database;
200 
201  bsoncxx::document::value as_bson() const;
202  stdx::optional<bsoncxx::string::view_or_value> _full_document;
203  stdx::optional<std::int32_t> _batch_size;
204  stdx::optional<bsoncxx::document::view_or_value> _collation;
205  stdx::optional<bsoncxx::document::view_or_value> _resume_after;
206  stdx::optional<bsoncxx::document::view_or_value> _start_after;
207  stdx::optional<std::chrono::milliseconds> _max_await_time;
208  // _start_at_operation_time is not wrapped in a stdx::optional because of a longstanding bug in
209  // the MNMLSTC polyfill that has been fixed on master, but not in the latest release:
210  // https://github.com/mnmlstc/core/pull/23
211  bsoncxx::types::b_timestamp _start_at_operation_time;
212  bool _start_at_operation_time_set = false;
213 };
214 } // namespace options
215 MONGOCXX_INLINE_NAMESPACE_END
216 } // namespace mongocxx
217 
218 #include <mongocxx/config/postlude.hpp>
mongocxx::options::change_stream::max_await_time
const stdx::optional< std::chrono::milliseconds > & max_await_time() const
The current max_time setting.
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
bsoncxx::view_or_value< document::view, document::value >
mongocxx::options::change_stream::collation
const stdx::optional< bsoncxx::document::view_or_value > & collation() const
Retrieves the current collation for this operation.
mongocxx::options::change_stream::collation
change_stream & collation(bsoncxx::document::view_or_value collation)
Sets the collation for this operation.
mongocxx::options::change_stream::resume_after
const stdx::optional< bsoncxx::document::view_or_value > & resume_after() const
Retrieves the current resumeToken for this change stream.
bsoncxx::document::value
A read-only BSON document that owns its underlying buffer.
Definition: value.hpp:33
mongocxx::options::change_stream::full_document
const bsoncxx::stdx::optional< bsoncxx::string::view_or_value > & full_document() const
Gets the current fullDocument setting.
bsoncxx::string::view_or_value
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:36
mongocxx::options::change_stream::start_after
change_stream & start_after(bsoncxx::document::view_or_value token)
Specifies the logical starting point of the new change stream.
bsoncxx::types::b_timestamp
A BSON replication timestamp value.
Definition: types.hpp:561
mongocxx::options::change_stream::start_after
const stdx::optional< bsoncxx::document::view_or_value > & start_after() const
Retrieves the current startAfter token for this change stream.
mongocxx::options::change_stream::full_document
change_stream & full_document(bsoncxx::string::view_or_value full_doc)
Sets the fullDocument stage for the $changeStream.
mongocxx::options::change_stream::resume_after
change_stream & resume_after(bsoncxx::document::view_or_value resume_after)
Specifies the logical starting point for the new change stream.
mongocxx::options::change_stream
Definition: change_stream.hpp:35
mongocxx::options::change_stream::batch_size
change_stream & batch_size(std::int32_t batch_size)
Sets the number of documents to return per batch.
mongocxx::options::change_stream::max_await_time
change_stream & max_await_time(std::chrono::milliseconds max_time)
Sets the maximum amount of time for for the server to wait on new documents to satisfy a change strea...
mongocxx::options::change_stream::start_at_operation_time
change_stream & start_at_operation_time(bsoncxx::types::b_timestamp timestamp)
Specifies the logical starting point for the new change stream.
mongocxx::options::change_stream::batch_size
const stdx::optional< std::int32_t > & batch_size() const
The current batch size setting.