summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/distinct.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2017-06-22 16:55:04 -0400
committerMathias Stearn <mathias@10gen.com>2017-07-13 16:53:12 -0400
commita6cc94d141f13feff33178a769c81282c7bc0170 (patch)
tree1a043a3718c54e8522f8b9bf0932c8d7f96ae79f /src/mongo/db/commands/distinct.cpp
parent8204c7dacf17851057dda165e6d1638cbff70cbf (diff)
downloadmongo-a6cc94d141f13feff33178a769c81282c7bc0170.tar.gz
SERVER-29731 Unify logic around directly invoking a command
Diffstat (limited to 'src/mongo/db/commands/distinct.cpp')
-rw-r--r--src/mongo/db/commands/distinct.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 521862f0ccf..ba72b5cd7a6 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -178,17 +178,16 @@ public:
if (!viewAggregation.isOK()) {
return appendCommandStatus(result, viewAggregation.getStatus());
}
- BSONObjBuilder aggResult;
- (void)Command::findCommand("aggregate")
- ->run(opCtx, dbname, viewAggregation.getValue(), errmsg, aggResult);
+ BSONObj aggResult = Command::runCommandDirectly(
+ opCtx, OpMsgRequest::fromDBAndBody(dbname, std::move(viewAggregation.getValue())));
- if (ResolvedView::isResolvedViewErrorResponse(aggResult.asTempObj())) {
- result.appendElements(aggResult.obj());
+ if (ResolvedView::isResolvedViewErrorResponse(aggResult)) {
+ result.appendElements(aggResult);
return false;
}
- ViewResponseFormatter formatter(aggResult.obj());
+ ViewResponseFormatter formatter(aggResult);
Status formatStatus = formatter.appendAsDistinctResponse(&result);
if (!formatStatus.isOK()) {
return appendCommandStatus(result, formatStatus);