diff options
Diffstat (limited to 'src/mongo/db/commands/user_management_commands.cpp')
-rw-r--r-- | src/mongo/db/commands/user_management_commands.cpp | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index c358b3957d6..d1d188c1274 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -62,13 +62,11 @@ #include "mongo/db/dbdirectclient.h" #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" +#include "mongo/db/ops/write_ops.h" #include "mongo/db/service_context.h" #include "mongo/platform/unordered_set.h" #include "mongo/rpc/get_status_from_command_result.h" #include "mongo/s/write_ops/batched_command_response.h" -#include "mongo/s/write_ops/batched_delete_request.h" -#include "mongo/s/write_ops/batched_insert_request.h" -#include "mongo/s/write_ops/batched_update_request.h" #include "mongo/stdx/functional.h" #include "mongo/stdx/mutex.h" #include "mongo/util/log.h" @@ -79,8 +77,6 @@ namespace mongo { -namespace str = mongoutils::str; - using std::endl; using std::string; using std::stringstream; @@ -271,12 +267,14 @@ Status insertAuthzDocument(OperationContext* opCtx, try { DBDirectClient client(opCtx); - BatchedInsertRequest req; - req.setNS(collectionName); - req.addToDocuments(document); - BSONObj res; - client.runCommand(collectionName.db().toString(), req.toBSON(), res); + client.runCommand(collectionName.db().toString(), + [&] { + write_ops::Insert insertOp(collectionName); + insertOp.setDocuments({document}); + return insertOp.toBSON({}); + }(), + res); BatchedCommandResponse response; std::string errmsg; @@ -305,18 +303,21 @@ Status updateAuthzDocuments(OperationContext* opCtx, try { DBDirectClient client(opCtx); - auto doc = stdx::make_unique<BatchedUpdateDocument>(); - doc->setQuery(query); - doc->setUpdateExpr(updatePattern); - doc->setMulti(multi); - doc->setUpsert(upsert); - - BatchedUpdateRequest req; - req.setNS(collectionName); - req.addToUpdates(doc.release()); - BSONObj res; - client.runCommand(collectionName.db().toString(), req.toBSON(), res); + client.runCommand(collectionName.db().toString(), + [&] { + write_ops::Update updateOp(collectionName); + updateOp.setUpdates({[&] { + write_ops::UpdateOpEntry entry; + entry.setQ(query); + entry.setU(updatePattern); + entry.setMulti(multi); + entry.setUpsert(upsert); + return entry; + }()}); + return updateOp.toBSON({}); + }(), + res); BatchedCommandResponse response; std::string errmsg; @@ -375,16 +376,19 @@ Status removeAuthzDocuments(OperationContext* opCtx, try { DBDirectClient client(opCtx); - auto doc = stdx::make_unique<BatchedDeleteDocument>(); - doc->setQuery(query); - doc->setLimit(0); - - BatchedDeleteRequest req; - req.setNS(collectionName); - req.addToDeletes(doc.release()); - BSONObj res; - client.runCommand(collectionName.db().toString(), req.toBSON(), res); + client.runCommand(collectionName.db().toString(), + [&] { + write_ops::Delete deleteOp(collectionName); + deleteOp.setDeletes({[&] { + write_ops::DeleteOpEntry entry; + entry.setQ(query); + entry.setMulti(true); + return entry; + }()}); + return deleteOp.toBSON({}); + }(), + res); BatchedCommandResponse response; std::string errmsg; |