MongoDB C++ Driver legacy-1.0.1
Loading...
Searching...
No Matches
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
24namespace 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
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary representa...
Definition bsonobj.h:78
Class for constructing and executing bulk operations against MongoDB via a fluent API.
Definition bulk_operation_builder.h:54
void insert(const BSONObj &doc)
Enqueues an insert write operation to be executed as part of the bulk operation.
void execute(const WriteConcern *writeConcern, WriteResult *writeResult)
Executes the bulk operation.
BulkUpdateBuilder find(const BSONObj &selector)
Supplies a filter to select a subset of documents on which to apply an operation.
BulkOperationBuilder(DBClientBase *const client, const std::string &ns, bool ordered)
BulkOperationBuilder constructor.
Class for constructing bulk write operations which have an applied filter.
Definition bulk_update_builder.h:31
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
Class to encapsulate client side "Write Concern" concept.
Definition write_concern.h:35
Represents a single server side write operation and encapsulates the process for encoding the operati...
Definition write_operation.h:31
Class representing the result of a write operations sent to the server.
Definition write_result.h:33
the main MongoDB namespace
Definition bulk_operation_builder.h:24