summaryrefslogtreecommitdiff
path: root/src/mongo/db/op_observer_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/op_observer_util.cpp')
-rw-r--r--src/mongo/db/op_observer_util.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/mongo/db/op_observer_util.cpp b/src/mongo/db/op_observer_util.cpp
index b1bc7074915..f7512cc21a7 100644
--- a/src/mongo/db/op_observer_util.cpp
+++ b/src/mongo/db/op_observer_util.cpp
@@ -42,21 +42,24 @@ namespace mongo {
*/
BSONObj makeCollModCmdObj(const BSONObj& collModCmd,
const CollectionOptions& oldCollOptions,
- boost::optional<TTLCollModInfo> ttlInfo) {
+ boost::optional<IndexCollModInfo> indexInfo) {
BSONObjBuilder cmdObjBuilder;
- std::string ttlIndexFieldName = "index";
+ std::string indexFieldName = "index";
// Add all fields from the original collMod command.
for (auto elem : collModCmd) {
// We normalize all TTL collMod oplog entry objects to use the index name, even if the
// command used an index key pattern.
- if (elem.fieldNameStringData() == ttlIndexFieldName && ttlInfo) {
- BSONObjBuilder ttlIndexObjBuilder;
- ttlIndexObjBuilder.append("name", ttlInfo->indexName);
- ttlIndexObjBuilder.append("expireAfterSeconds",
- durationCount<Seconds>(ttlInfo->expireAfterSeconds));
+ if (elem.fieldNameStringData() == indexFieldName && indexInfo) {
+ BSONObjBuilder indexObjBuilder;
+ indexObjBuilder.append("name", indexInfo->indexName);
+ if (indexInfo->expireAfterSeconds)
+ indexObjBuilder.append("expireAfterSeconds",
+ durationCount<Seconds>(indexInfo->expireAfterSeconds.get()));
+ if (indexInfo->unique)
+ indexObjBuilder.append("unique", indexInfo->unique.get());
- cmdObjBuilder.append(ttlIndexFieldName, ttlIndexObjBuilder.obj());
+ cmdObjBuilder.append(indexFieldName, indexObjBuilder.obj());
} else {
cmdObjBuilder.append(elem);
}