summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/count.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2014-09-10 15:47:51 -0400
committerDavid Storch <david.storch@10gen.com>2014-09-11 10:19:42 -0400
commite27b158000b01fe4c505961fefe5a77efbfe8a3e (patch)
tree14836727909c5f29ae234a0e1bff452cd0e54c9e /src/mongo/db/commands/count.cpp
parente1c24123e023b47d8b279f77ba00cbf61e5a1347 (diff)
downloadmongo-e27b158000b01fe4c505961fefe5a77efbfe8a3e.tar.gz
SERVER-14799 hint for a count allows hint to be specified as a document
Diffstat (limited to 'src/mongo/db/commands/count.cpp')
-rw-r--r--src/mongo/db/commands/count.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mongo/db/commands/count.cpp b/src/mongo/db/commands/count.cpp
index c8f1e95bb59..f5dd51ab18b 100644
--- a/src/mongo/db/commands/count.cpp
+++ b/src/mongo/db/commands/count.cpp
@@ -166,8 +166,14 @@ namespace mongo {
query = cmdObj.getObjectField("query");
}
- const std::string hint = cmdObj.getStringField("hint");
- const BSONObj hintObj = hint.empty() ? BSONObj() : BSON("$hint" << hint);
+ BSONObj hintObj;
+ if (Object == cmdObj["hint"].type()) {
+ hintObj = cmdObj["hint"].Obj();
+ }
+ else if (String == cmdObj["hint"].type()) {
+ const std::string hint = cmdObj.getStringField("hint");
+ hintObj = BSON("$hint" << hint);
+ }
// Parsed correctly. Fill out 'request' with the results.
request->ns = ns;