summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document.h')
-rw-r--r--src/mongo/db/pipeline/document.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/document.h b/src/mongo/db/pipeline/document.h
index 5e5980f5a51..a8ebfd1c4d2 100644
--- a/src/mongo/db/pipeline/document.h
+++ b/src/mongo/db/pipeline/document.h
@@ -90,6 +90,12 @@ public:
const Document& rhs;
};
+ static constexpr StringData metaFieldTextScore = "$textScore"_sd;
+ static constexpr StringData metaFieldRandVal = "$randVal"_sd;
+ static constexpr StringData metaFieldSortKey = "$sortKey"_sd;
+
+ static const std::vector<StringData> allMetadataFieldNames;
+
/// Empty Document (does no allocation)
Document() {}
@@ -211,6 +217,12 @@ public:
*/
static Document fromBsonWithMetaData(const BSONObj& bson);
+ /**
+ * Given a BSON object that may have metadata fields added as part of toBsonWithMetadata(),
+ * returns the same object without any of the metadata fields.
+ */
+ static BSONObj stripMetadataFields(const BSONObj& bsonWithMetadata);
+
// Support BSONObjBuilder and BSONArrayBuilder "stream" API
friend BSONObjBuilder& operator<<(BSONObjBuilderValueStream& builder, const Document& d);
@@ -233,7 +245,6 @@ public:
return Document(storage().clone().get());
}
- static const StringData metaFieldTextScore; // "$textScore"
bool hasTextScore() const {
return storage().hasTextScore();
}
@@ -241,7 +252,6 @@ public:
return storage().getTextScore();
}
- static const StringData metaFieldRandVal; // "$randVal"
bool hasRandMetaField() const {
return storage().hasRandMetaField();
}
@@ -249,6 +259,13 @@ public:
return storage().getRandMetaField();
}
+ bool hasSortKeyMetaField() const {
+ return storage().hasSortKeyMetaField();
+ }
+ BSONObj getSortKeyMetaField() const {
+ return storage().getSortKeyMetaField();
+ }
+
/// members for Sorter
struct SorterDeserializeSettings {}; // unused
void serializeForSorter(BufBuilder& buf) const;
@@ -493,6 +510,10 @@ public:
storage().setRandMetaField(val);
}
+ void setSortKeyMetaField(BSONObj sortKey) {
+ storage().setSortKeyMetaField(sortKey);
+ }
+
/** Convert to a read-only document and release reference.
*
* Call this to indicate that you are done with this Document and will