My objective is to extract the operation count from MongoDB clustertime.
I.e. in other words, how do I get this "i" value in a pipeline?
Currently we "extract" the time like this:
$addFields: {
clusterTimeAsDate: {
$toDate: { $dateToString: { date: '$clusterTime' } },
},
}
CodePudding user response:
Assuming the question is about aggregation, there will be $tsIncrement
operator added in v5.1 https://jira.mongodb.org/browse/SERVER-56874.
Must be something like this:
$addFields: {
clusterTimeAsDate: {
$toDate: { $dateToString: { date: '$clusterTime' } },
},
clusterTimeIncrement: { $tsIncrement: '$clusterTime' }
}
update
It might be more efficient to use $tsSecond
to convert to Date when you upgrade.