[SERVER-40266] Add on modified option to $currentDate Created: 21/Mar/19 Updated: 25/Mar/19 Resolved: 22/Mar/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Bryan Lee | Assignee: | Danny Hatcher (Inactive) |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
$currentDate will set the current date regardless of whether the document was otherwise modified. It would be helpful to have an option to set the current time only if fields other than those specified in $currentDate are changed from their original values as returned in the nModified count, similar to MySQL's ON UPDATE CURRENT_TIMESTAMP. Using change streams or tailing oplog could accomplish such, but requires replication. |
| Comments |
| Comment by Bryan Lee [ 25/Mar/19 ] | |||||||||||||||||||||||||
|
Ah yes, | |||||||||||||||||||||||||
| Comment by Asya Kamsky [ 23/Mar/19 ] | |||||||||||||||||||||||||
|
bryanleepartstree I think either | |||||||||||||||||||||||||
| Comment by Bryan Lee [ 22/Mar/19 ] | |||||||||||||||||||||||||
|
Thanks for the feedback, but I'd like to differentiate between "updated" and "modified". Ticket The write result of an update request includes nModified, which is only greater than one if a value in the document has changed from its original value, which is why nMatched might be greater than nModified. My request is to examine whether or not it's possible to leverage the knowledge of document state change in determining whether or not the $currentDate op should be fulfilled.
Example: If we have a collection with the following document
And issue an update
The response would return nModified : 0, and the document would remain the same
However if I issue an update with $currentDate
The response would return nModified : 1, and lastModified would contain the date of the writeOp. I am recommending an option to only fulfill the $currentDate op if nModified would otherwise return >0
Something like
But
| |||||||||||||||||||||||||
| Comment by Danny Hatcher (Inactive) [ 22/Mar/19 ] | |||||||||||||||||||||||||
|
Hello Bryan, Thanks for your feature request! There is an existing ticket open as As such, I will close this ticket as a duplicate. Thanks, Danny |