MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / ExtUpdateOperatorCurrentDate

Class ExtUpdateOperatorCurrentDate

src/ExtOperator.actor.cpp:935–956  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

933REGISTER_UPDATE_OPERATOR(ExtUpdateOperatorAddToSet, "$addToSet");
934
935struct ExtUpdateOperatorCurrentDate {
936 static const char* name;
937 static Future<Void> execute(Reference<IReadWriteContext> cx,
938 StringRef const& path,
939 bson::BSONElement const& element) {
940 if (element.isBoolean() && element.Bool()) {
941 DataValue dv = DataValue(bson::Date_t(timer() * 1000));
942 cx->getSubContext(path)->clearDescendants();
943 cx->set(path, dv.encode_value());
944 } else if (element.isABSONObj() && element.Obj().hasField("$type")) {
945 auto typeField = element.Obj().getField("$type");
946 if (typeField.isString() && typeField.String() == "date") {
947 DataValue dv = DataValue(bson::Date_t(timer() * 1000));
948 cx->getSubContext(path)->clearDescendants();
949 cx->set(path, dv.encode_value());
950 } else if (typeField.isString() && typeField.String() == "timestamp") {
951 throw no_mongo_timestamps();
952 }
953 }
954 return Void();
955 }
956};
957REGISTER_UPDATE_OPERATOR(ExtUpdateOperatorCurrentDate, "$currentDate");
958
959ACTOR static Future<Void> getAndCompare(Reference<IReadWriteContext> cx,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected