-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
Hello,
I don't know if it's possible because I don't know the mechanics inside the update process well enough, but I thought this would be interesting to extend the $currentDate operator to update the date if and only if (optionnaly) at least 1 other fields in document was updated.
As an example, imagine I have a document :
{"_id": 1, "firstname":"Henri", "du":ISODate("2017-04-12T19:10:28.000Z")}
And this update request :
db.test.update({"firstname": "Henri"}, { "$set":{"firstname": "Henri"}, "$currentDate":{"du": true} }, { "upsert": true } );
Appart from the $currentDate, this update does not actually update anything in the document. And I thought this would be useful to have $currentDate update the "du" fields only if firstname had changed.
Maybe there is a design pattern to do that another way, but in my application, I have to do a lot of bulk updates and sometimes, with data that has already been written and thus, updates doing nothing...
Thanks for any input on the matter.