Skip to content

Commit 3a35d1b

Browse files
committed
incorporate review feedback to add an additional optional argument instead of an overloaded function
1 parent 526ca26 commit 3a35d1b

File tree

3 files changed

+11
-35
lines changed

3 files changed

+11
-35
lines changed

src/mongocxx/collection.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,23 +1308,15 @@ void collection::_drop(const client_session* session,
13081308
}
13091309
}
13101310

1311-
void collection::drop(const stdx::optional<mongocxx::write_concern>& wc) {
1312-
return _drop(nullptr, wc, {});
1311+
void collection::drop(const stdx::optional<mongocxx::write_concern>& wc,
1312+
bsoncxx::document::view_or_value collection_options) {
1313+
return _drop(nullptr, wc, collection_options);
13131314
}
13141315

13151316
void collection::drop(const client_session& session,
1316-
const stdx::optional<mongocxx::write_concern>& wc) {
1317-
return _drop(&session, wc, {});
1318-
}
1319-
1320-
// From the spec:
1321-
// https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#user-facing-api
1322-
// > Drivers MUST support a BSON document option named encryptedFields for any
1323-
// > drop command helpers (e.g. Database.dropCollection(), Collection.drop()).
1324-
// > This option will only be interpreted by the helper method and MUST NOT be
1325-
// > passed to the drop command.
1326-
void collection::drop(bsoncxx::document::view_or_value collection_options) {
1327-
return _drop(nullptr, {}, collection_options);
1317+
const stdx::optional<mongocxx::write_concern>& wc,
1318+
bsoncxx::document::view_or_value collection_options) {
1319+
return _drop(&session, wc, collection_options);
13281320
}
13291321

13301322
void collection::read_concern(class read_concern rc) {

src/mongocxx/collection.hpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,8 @@ class MONGOCXX_API collection {
699699
/// @note
700700
/// Write concern supported only for MongoDB 3.4+.
701701
///
702-
void drop(const bsoncxx::stdx::optional<mongocxx::write_concern>& write_concern = {});
702+
void drop(const bsoncxx::stdx::optional<mongocxx::write_concern>& write_concern = {},
703+
bsoncxx::document::view_or_value collection_options = {});
703704

704705
///
705706
/// Drops this collection and all its contained documents from the database.
@@ -720,25 +721,8 @@ class MONGOCXX_API collection {
720721
/// Write concern supported only for MongoDB 3.4+.
721722
///
722723
void drop(const client_session& session,
723-
const bsoncxx::stdx::optional<mongocxx::write_concern>& write_concern = {});
724-
725-
///
726-
/// Drops this collection and all its contained documents from the database.
727-
///
728-
/// @param collection_options
729-
/// the options for the dropped collection.
730-
///
731-
/// @exception
732-
/// mongocxx::operation_exception if the operation fails.
733-
///
734-
/// @see
735-
/// https://docs.mongodb.com/manual/reference/command/drop/
736-
/// https://mongoc.org/libmongoc/current/mongoc_collection_drop_with_opts.html
737-
///
738-
/// @note
739-
/// Needed for Queryable Encryption Support.
740-
///
741-
void drop(bsoncxx::document::view_or_value collection_options);
724+
const bsoncxx::stdx::optional<mongocxx::write_concern>& write_concern = {},
725+
bsoncxx::document::view_or_value collection_options = {});
742726

743727
///
744728
/// @}

src/mongocxx/test/spec/operation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ document::value operation_runner::_run_drop_collection(document::view operation)
13091309
if (arguments.find("encryptedFields") != arguments.end()) {
13101310
auto encrypted_fields = arguments["encryptedFields"].get_document().value;
13111311
auto encrypted_fields_map = make_document(kvp("encryptedFields", encrypted_fields));
1312-
_db->collection(collection_name).drop(std::move(encrypted_fields_map));
1312+
_db->collection(collection_name).drop(stdx::nullopt, std::move(encrypted_fields_map));
13131313
} else {
13141314
_db->collection(collection_name).drop();
13151315
}

0 commit comments

Comments
 (0)