MongoDB C++ Driver  legacy-1.1.2
bulk_operation_builder.h
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 
16 #pragma once
17 
18 #include <vector>
19 
20 #include "mongo/bson/bsonobj.h"
21 #include "mongo/client/bulk_update_builder.h"
22 #include "mongo/client/write_result.h"
23 
24 namespace mongo {
25 
26 class DBClientBase;
27 class WriteConcern;
28 class WriteOperation;
29 
54 class MONGO_CLIENT_API BulkOperationBuilder {
55  /* Enable operations of this type to append themselves to enqueue themselves */
56  friend class BulkUpdateBuilder;
57 
58  /* Enable operations of this type to append themselves to enqueue themselves */
59  friend class BulkUpsertBuilder;
60 
61 public:
73  BulkOperationBuilder(DBClientBase* const client,
74  const std::string& ns,
75  bool ordered,
76  bool bypassDocumentValidation = false);
77 
78  /* Deletes all of the WriteOperations that were created during the Builder's lifetime */
80 
89  BulkUpdateBuilder find(const BSONObj& selector);
90 
96  void insert(const BSONObj& doc);
97 
104  void execute(const WriteConcern* writeConcern, WriteResult* writeResult);
105 
106 private:
107  void enqueue(WriteOperation* const operation);
108 
109  DBClientBase* const _client;
110  const std::string _ns;
111  const bool _ordered;
112  const bool _bypassDocumentValidation;
113  bool _executed;
114  size_t _currentIndex;
115  std::vector<WriteOperation*> _write_operations;
116 };
117 
118 } // namespace mongo
Represents a single server side write operation and encapsulates the process for encoding the operati...
Definition: write_operation.h:31
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
Class for constructing and executing bulk operations against MongoDB via a fluent API...
Definition: bulk_operation_builder.h:54
Class for constructing bulk write operations which have an applied filter.
Definition: bulk_update_builder.h:31
Class representing the result of a write operations sent to the server.
Definition: write_result.h:33
Class to encapsulate client side "Write Concern" concept.
Definition: write_concern.h:35
Class for constructing bulk write operations which have an applied filter and are to be performed as ...
Definition: bulk_upsert_builder.h:31
abstract class that implements the core db operations
Definition: dbclientinterface.h:1422
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary represent...
Definition: bsonobj.h:78