summaryrefslogtreecommitdiff
path: root/src/mongo/client/dbclient_cursor.cpp
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2020-09-30 23:37:25 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-01 05:24:34 +0000
commitd286a563d4ad921331d7d3846181a5bb7192a31d (patch)
tree35229ff3b0dd0a89c6986e0221a805bdb7e5903c /src/mongo/client/dbclient_cursor.cpp
parente66093f0a8ee3cd95dea9480028a6da814bb1854 (diff)
downloadmongo-d286a563d4ad921331d7d3846181a5bb7192a31d.tar.gz
SERVER-49893: Do oplog fetching.
Diffstat (limited to 'src/mongo/client/dbclient_cursor.cpp')
-rw-r--r--src/mongo/client/dbclient_cursor.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mongo/client/dbclient_cursor.cpp b/src/mongo/client/dbclient_cursor.cpp
index 7e83de38bc0..259d032da62 100644
--- a/src/mongo/client/dbclient_cursor.cpp
+++ b/src/mongo/client/dbclient_cursor.cpp
@@ -591,6 +591,34 @@ DBClientCursor::DBClientCursor(DBClientBase* client,
}
}
+/* static */
+StatusWith<std::unique_ptr<DBClientCursor>> DBClientCursor::fromAggregationRequest(
+ DBClientBase* client, AggregationRequest aggRequest, bool secondaryOk, bool useExhaust) {
+ BSONObj ret;
+ try {
+ if (!client->runCommand(aggRequest.getNamespaceString().db().toString(),
+ aggRequest.serializeToCommandObj().toBson(),
+ ret,
+ secondaryOk ? QueryOption_SlaveOk : 0)) {
+ return {ErrorCodes::CommandFailed, ret.toString()};
+ }
+ } catch (...) {
+ return exceptionToStatus();
+ }
+ long long cursorId = ret["cursor"].Obj()["id"].Long();
+ std::vector<BSONObj> firstBatch;
+ for (BSONElement elem : ret["cursor"].Obj()["firstBatch"].Array()) {
+ firstBatch.emplace_back(elem.Obj().getOwned());
+ }
+
+ return {std::make_unique<DBClientCursor>(client,
+ aggRequest.getNamespaceString(),
+ cursorId,
+ 0,
+ useExhaust ? QueryOption_Exhaust : 0,
+ firstBatch)};
+}
+
DBClientCursor::~DBClientCursor() {
kill();
}