summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document.cpp
diff options
context:
space:
mode:
authorCharlie Swanson <cswanson310@gmail.com>2016-03-28 10:21:22 -0400
committerCharlie Swanson <cswanson310@gmail.com>2016-03-30 13:48:25 -0400
commite64e2aca73f7b3b7184c1b5cc8b6c3ff3af79f21 (patch)
tree9654aa5e488aaac4cbd5861e1f6cea404cbeced5 /src/mongo/db/pipeline/document.cpp
parent25d43de2204dadb2cf2a4bf7eed3a7d374fc98db (diff)
downloadmongo-e64e2aca73f7b3b7184c1b5cc8b6c3ff3af79f21.tar.gz
SERVER-23371 Add initializer_list constructor for Documents.
Diffstat (limited to 'src/mongo/db/pipeline/document.cpp')
-rw-r--r--src/mongo/db/pipeline/document.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document.cpp b/src/mongo/db/pipeline/document.cpp
index 6b2cf793aba..f7c8b179094 100644
--- a/src/mongo/db/pipeline/document.cpp
+++ b/src/mongo/db/pipeline/document.cpp
@@ -227,6 +227,16 @@ Document::Document(const BSONObj& bson) {
*this = md.freeze();
}
+Document::Document(std::initializer_list<std::pair<StringData, ImplicitValue>> initializerList) {
+ MutableDocument mutableDoc(initializerList.size());
+
+ for (auto&& pair : initializerList) {
+ mutableDoc.addField(pair.first, pair.second);
+ }
+
+ *this = mutableDoc.freeze();
+}
+
BSONObjBuilder& operator<<(BSONObjBuilderValueStream& builder, const Document& doc) {
BSONObjBuilder subobj(builder.subobjStart());
doc.toBson(&subobj);