1- // Copyright 2014 MongoDB Inc.
1+ // Copyright 2014-present MongoDB Inc.
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
5252#include < mongocxx/result/insert_one.hpp>
5353#include < mongocxx/result/replace_one.hpp>
5454#include < mongocxx/result/update.hpp>
55+ #include < mongocxx/session.hpp>
5556#include < mongocxx/write_concern.hpp>
5657
5758#include < mongocxx/config/prelude.hpp>
@@ -144,6 +145,8 @@ class MONGOCXX_API collection {
144145 cursor aggregate (const pipeline& pipeline,
145146 const options::aggregate& options = options::aggregate());
146147
148+ // /
149+ // / @{
147150 // /
148151 // / Creates a new bulk operation to be executed against this collection.
149152 // /
@@ -155,6 +158,23 @@ class MONGOCXX_API collection {
155158 // /
156159 class bulk_write create_bulk_write (const options::bulk_write& options = {});
157160
161+ // /
162+ // / Creates a new bulk operation to be executed against this collection.
163+ // /
164+ // / @param session
165+ // / The mongocxx::session with which to perform the bulk operation.
166+ // / @param options
167+ // / Optional arguments; see mongocxx::options::bulk_write.
168+ // /
169+ // / @return
170+ // / The newly-created bulk write.
171+ // /
172+ class bulk_write create_bulk_write (const session& session,
173+ const options::bulk_write& options = {});
174+ // /
175+ // / @}
176+ // /
177+
158178 // /
159179 // / Sends a write to the server as a bulk write operation.
160180 // /
@@ -167,7 +187,7 @@ class MONGOCXX_API collection {
167187 // / The optional result of the bulk operation execution.
168188 // / If the write concern is unacknowledged, the optional will be
169189 // / disengaged.
170- //
190+ // /
171191 // / @exception
172192 // / mongocxx::bulk_write_exception when there are errors processing
173193 // / the writes.
@@ -193,7 +213,7 @@ class MONGOCXX_API collection {
193213 // / @return The optional result of the bulk operation execution.
194214 // / If the write concern is unacknowledged, the optional will be
195215 // / disengaged.
196- //
216+ // /
197217 // / @throws mongocxx::bulk_write_exception when there are errors processing the writes.
198218 // /
199219 // / @see mongocxx::bulk_write
@@ -471,6 +491,8 @@ class MONGOCXX_API collection {
471491 bsoncxx::document::view_or_value update,
472492 const options::find_one_and_update& options = options::find_one_and_update());
473493
494+ // /
495+ // / @{
474496 // /
475497 // / Inserts a single document into the collection. If the document is missing an identifier
476498 // / (@c _id field) one will be generated for it.
@@ -485,10 +507,30 @@ class MONGOCXX_API collection {
485507 // / disengaged.
486508 // /
487509 // / @throws mongocxx::bulk_write_exception if the operation fails.
510+ stdx::optional<result::insert_one> insert_one (bsoncxx::document::view_or_value document,
511+ const options::insert& options = {});
512+ // /
513+ // / Inserts a single document into the collection. If the document is missing an identifier
514+ // / (@c _id field) one will be generated for it.
515+ // /
516+ // / @param document
517+ // / The document to insert.
518+ // / @param session
519+ // / The mongocxx::session with which to perform the insert.
520+ // / @param options
521+ // / Optional arguments, see options::insert.
522+ // /
523+ // / @return The optional result of attempting to perform the insert.
524+ // / If the write concern is unacknowledged, the optional will be
525+ // / disengaged.
526+ // /
527+ // / @throws mongocxx::bulk_write_exception if the operation fails.
528+ stdx::optional<result::insert_one> insert_one (bsoncxx::document::view_or_value document,
529+ const session& session,
530+ const options::insert& options = {});
531+ // /
532+ // / @}
488533 // /
489- stdx::optional<result::insert_one> insert_one (
490- bsoncxx::document::view_or_value document,
491- const options::insert& options = options::insert());
492534
493535 // /
494536 // / Inserts multiple documents into the collection. If any of the documents are missing
@@ -497,7 +539,7 @@ class MONGOCXX_API collection {
497539 // / @warning This method uses the bulk insert command to execute the insertion as opposed to
498540 // / the legacy OP_INSERT wire protocol message. As a result, using this method to insert many
499541 // / documents on MongoDB < 2.6 will be slow.
500- //
542+ // /
501543 // / @tparam containter_type
502544 // / The container type. Must meet the requirements for the container concept with a value
503545 // / type of model::write.
@@ -729,6 +771,11 @@ class MONGOCXX_API collection {
729771
730772 MONGOCXX_PRIVATE collection (const database& database, void * collection);
731773
774+ MONGOCXX_PRIVATE stdx::optional<result::insert_one> _insert_one (
775+ bsoncxx::document::view_or_value document,
776+ const options::insert& options,
777+ const session* session = nullptr );
778+
732779 class MONGOCXX_PRIVATE impl;
733780
734781 MONGOCXX_PRIVATE impl& _get_impl ();
0 commit comments