MongoDB C++ Driver  mongocxx-3.6.2
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
update_many.hpp
1 // Copyright 2014 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 <bsoncxx/array/view_or_value.hpp>
18 #include <bsoncxx/document/view_or_value.hpp>
19 #include <bsoncxx/stdx/optional.hpp>
20 #include <mongocxx/hint.hpp>
21 #include <mongocxx/stdx.hpp>
22 
23 #include <mongocxx/config/prelude.hpp>
24 #include <mongocxx/pipeline.hpp>
25 
26 namespace mongocxx {
27 MONGOCXX_INLINE_NAMESPACE_BEGIN
28 
29 namespace model {
30 
34 class MONGOCXX_API update_many {
35  //
36  // Utility class supporting the convenience of {} meaning an empty bsoncxx::document.
37  //
38  // Users may not use this class directly.
39  //
40  // In places where driver methods take this class as a parameter, passing {} will
41  // translate to a default-constructed bsoncxx::document::view_or_value,
42  // regardless of other overloads taking other default-constructible types
43  // for that parameter. This class avoids compiler ambiguity with such overloads.
44  //
45  // See update_many() for an example of such overloads.
46  //
47  class _empty_doc_tag {
48  _empty_doc_tag() = default;
49  };
50 
51  public:
63 
73 
83  std::initializer_list<_empty_doc_tag> update);
84 
88 
95 
102 
113 
123  const stdx::optional<bsoncxx::document::view_or_value>& collation() const;
124 
137  update_many& hint(class hint index_hint);
138 
144  const stdx::optional<class hint>& hint() const;
145 
159  update_many& upsert(bool upsert);
160 
166  const stdx::optional<bool>& upsert() const;
167 
177 
186  const stdx::optional<bsoncxx::array::view_or_value>& array_filters() const;
187 
188  private:
191 
192  stdx::optional<bsoncxx::document::view_or_value> _collation;
193  stdx::optional<bsoncxx::array::view_or_value> _array_filters;
194  stdx::optional<bool> _upsert;
195  stdx::optional<class hint> _hint;
196 };
197 
198 } // namespace model
199 MONGOCXX_INLINE_NAMESPACE_END
200 } // namespace mongocxx
201 
202 #include <mongocxx/config/postlude.hpp>
mongocxx::model::update_many::collation
update_many & collation(bsoncxx::document::view_or_value collation)
Sets the collation for this update operation.
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::model::update_many::update
const bsoncxx::document::view_or_value & update() const
Gets the update document.
bsoncxx::view_or_value
Class representing a view-or-value variant type.
Definition: view_or_value.hpp:30
mongocxx::model::update_many::update_many
update_many(bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value update)
Constructs an update operation that will modify all documents matching the filter.
mongocxx::model::update_many::hint
update_many & hint(class hint index_hint)
Sets the index to use for this operation.
mongocxx::model::update_many::filter
const bsoncxx::document::view_or_value & filter() const
Gets the filter.
mongocxx::model::update_many::array_filters
update_many & array_filters(bsoncxx::array::view_or_value array_filters)
Set array filters for this update operation.
mongocxx::model::update_many::update_many
update_many(bsoncxx::document::view_or_value filter, const pipeline &update)
Constructs an update operation that will modify all documents matching the filter.
mongocxx::model::update_many::upsert
const stdx::optional< bool > & upsert() const
Gets the current value of the upsert option.
mongocxx::model::update_many::update_many
update_many(bsoncxx::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update)
Constructs an update operation that will modify all documents matching the filter.
mongocxx::model::update_many::hint
const stdx::optional< class hint > & hint() const
Gets the current hint.
mongocxx::hint
Class representing a hint to be passed to a database operation.
Definition: hint.hpp:32
mongocxx::pipeline
Class representing a MongoDB aggregation pipeline.
Definition: pipeline.hpp:38
mongocxx::model::update_many::upsert
update_many & upsert(bool upsert)
Sets the upsert option.
mongocxx::model::update_many
Class representing a MongoDB update operation that modifies multiple documents.
Definition: update_many.hpp:34
mongocxx::model::update_many::array_filters
const stdx::optional< bsoncxx::array::view_or_value > & array_filters() const
Get array filters for this operation.
mongocxx::model::update_many::collation
const stdx::optional< bsoncxx::document::view_or_value > & collation() const
Gets the collation option for this update operation.