[SERVER-40406] Add support for '$$NOW' and '$$CLUSTER_TIME' within the update command Created: 01/Apr/19 Updated: 29/Oct/23 Resolved: 17/May/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework, Write Ops |
| Affects Version/s: | None |
| Fix Version/s: | 4.1.12 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Charlie Swanson | Assignee: | Bernard Gorman |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Sprint: | Query 2019-05-20, Query 2019-06-03 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
This will likely involve accepting an additional argument to the update command, like we do for 'runtimeConstants' in aggregate. It will also involve propagating those constants from the update command on mongos or generating them on mongod in unsharded deployments. |
| Comments |
| Comment by Adrian B [ 06/Jul/21 ] |
|
It seems that only the update with aggregation pipeline can use $$NOW. Could it also be supported in the "classical" update (with update operators) ? I know $currentDate exists, but we cannot use it combined with another update operator ($setOnInsert, $push, ...) and sometime, using an update with aggregation pipeline would be unfavorable. Example of use case :
If we use an update with aggregation pipeline, each insertion of elements in the array with $concatArray will triggers an event containing all the content of the array. Note (if you are curious of my specific use case) : the "creation-time" is needed because we want to atomically (with only one operation) adds elements to an array in a "chunk" (or create one if chunk size is already at the limit), while allowing to retrieve the chunks in order. This would allow us to have an array of subdocuments (events) unrestricted to the 16 MB limit, while allowing to use a change stream to retrieve the events' data.
|
| Comment by Githook User [ 17/May/19 ] |
|
Author: {'email': 'bernard.gorman@gmail.com', 'name': 'Bernard Gorman', 'username': 'gormanb'}Message: |