summaryrefslogtreecommitdiff
path: root/src/mongo/db/keypattern.h
diff options
context:
space:
mode:
authorJamie Heppenstall <jamie.heppenstall@mongodb.com>2019-06-17 14:42:54 -0400
committerJamie Heppenstall <jamie.heppenstall@mongodb.com>2019-07-12 16:59:06 -0400
commit6e02a4d34bd972e6755bb5f71a5b26f69fe2cfb0 (patch)
tree1a68aa771c357aceb88686004b4f2e730afa17d2 /src/mongo/db/keypattern.h
parent75e47b701d34c9ef7beb0482121ac8b62d2d4991 (diff)
downloadmongo-6e02a4d34bd972e6755bb5f71a5b26f69fe2cfb0.tar.gz
SERVER-41658 Convert ShardCollectionType into an IDL type
Diffstat (limited to 'src/mongo/db/keypattern.h')
-rw-r--r--src/mongo/db/keypattern.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/db/keypattern.h b/src/mongo/db/keypattern.h
index d87bc8632c5..ac31301b7f2 100644
--- a/src/mongo/db/keypattern.h
+++ b/src/mongo/db/keypattern.h
@@ -29,6 +29,7 @@
#pragma once
+#include "mongo/base/status.h"
#include "mongo/base/string_data.h"
#include "mongo/bson/util/builder.h"
#include "mongo/db/jsobj.h"
@@ -68,10 +69,20 @@ public:
static bool isHashedKeyPattern(const BSONObj& pattern);
/**
- * Constructs a new key pattern based on a BSON document
+ * Constructs a new key pattern based on a BSON document.
+ * Used as an interface to the IDL parser.
+ */
+ static KeyPattern fromBSON(const BSONObj& pattern) {
+ return KeyPattern(pattern.getOwned());
+ }
+
+ /**
+ * Constructs a new key pattern based on a BSON document.
*/
KeyPattern(const BSONObj& pattern);
+ explicit KeyPattern() = default;
+
/**
* Returns a BSON representation of this KeyPattern.
*/
@@ -80,7 +91,7 @@ public:
}
/**
- * Returns a string representation of this KeyPattern
+ * Returns a string representation of this KeyPattern.
*/
std::string toString() const {
return str::stream() << *this;