summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/update/current_date_node.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/update/current_date_node.cpp b/src/mongo/db/update/current_date_node.cpp
index 9df15695850..4933c8adcf9 100644
--- a/src/mongo/db/update/current_date_node.cpp
+++ b/src/mongo/db/update/current_date_node.cpp
@@ -27,6 +27,8 @@
* it in the license file.
*/
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrite
+
#include "mongo/platform/basic.h"
#include "mongo/db/update/current_date_node.h"
@@ -34,6 +36,8 @@
#include "mongo/db/logical_clock.h"
#include "mongo/db/logical_time.h"
#include "mongo/db/service_context.h"
+#include "mongo/util/debug_util.h"
+#include "mongo/util/log.h"
namespace mongo {
@@ -42,6 +46,8 @@ constexpr StringData kType = "$type"_sd;
constexpr StringData kDate = "date"_sd;
constexpr StringData kTimestamp = "timestamp"_sd;
+Rarely currentDateDeprecationSampler; // Used to occasionally log deprecation messages.
+
void setValue(mutablebson::Element* element, bool typeIsDate) {
if (typeIsDate) {
invariant(element->setValueDate(mongo::jsTime()));
@@ -56,6 +62,12 @@ Status CurrentDateNode::init(BSONElement modExpr,
const boost::intrusive_ptr<ExpressionContext>& expCtx) {
invariant(modExpr.ok());
+ if (currentDateDeprecationSampler.tick()) {
+ warning() << "The $currentDate update operator is deprecated. As an alternative perform "
+ "updates with an aggregation pipeline and either the 'NOW' or 'CLUSTER_TIME' "
+ "system variables.";
+ }
+
if (modExpr.type() == BSONType::Bool) {
_typeIsDate = true;
} else if (modExpr.type() == BSONType::Object) {