summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_path_support.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_path_support.h')
-rw-r--r--src/mongo/db/pipeline/document_path_support.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/document_path_support.h b/src/mongo/db/pipeline/document_path_support.h
index 5d9f0a1cb6b..b1c127af0e4 100644
--- a/src/mongo/db/pipeline/document_path_support.h
+++ b/src/mongo/db/pipeline/document_path_support.h
@@ -63,7 +63,14 @@ StatusWith<Value> extractElementAlongNonArrayPath(const Document& doc, const Fie
/**
* Extracts 'paths' from the input document and returns a BSON object containing only those paths.
*/
-BSONObj documentToBsonWithPaths(const Document&, const std::set<std::string>& paths);
+void documentToBsonWithPaths(const Document&, const OrderedPathSet& paths, BSONObjBuilder* builder);
+
+template <typename BSONTraits = BSONObj::DefaultSizeTrait>
+BSONObj documentToBsonWithPaths(const Document& input, const OrderedPathSet& paths) {
+ BSONObjBuilder outputBuilder;
+ documentToBsonWithPaths(input, paths, &outputBuilder);
+ return outputBuilder.obj<BSONTraits>();
+}
/**
* Extracts 'paths' from the input document to a flat document.