MongoDB C++ Driver  legacy-1.0.5
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 
56  /* Enable operations of this type to append themselves to enqueue themselves */
57  friend class BulkUpdateBuilder;
58 
59  /* Enable operations of this type to append themselves to enqueue themselves */
60  friend class BulkUpsertBuilder;
61 
62  public:
73  BulkOperationBuilder(DBClientBase* const client, const std::string& ns, bool ordered);
74 
75  /* Deletes all of the WriteOperations that were created during the Builder's lifetime */
77 
86  BulkUpdateBuilder find(const BSONObj& selector);
87 
93  void insert(const BSONObj& doc);
94 
101  void execute(const WriteConcern* writeConcern, WriteResult* writeResult);
102 
103  private:
104  void enqueue(WriteOperation* const operation);
105 
106  DBClientBase* const _client;
107  const std::string _ns;
108  const bool _ordered;
109  bool _executed;
110  size_t _currentIndex;
111  std::vector<WriteOperation*> _write_operations;
112  };
113 
114 } // namespace mongo
Represents a single server side write operation and encapsulates the process for encoding the operati...
Definition: write_operation.h:31
the main MongoDB namespace
Definition: bulk_operation_builder.h:24
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:1330
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary represent...
Definition: bsonobj.h:78