File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
reference/operator/update Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change
1
+ :update: `$currentDate ` sets the specified field to the date when
2
+ :update: `$currentDate ` was run.
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ Behavior
43
43
44
44
.. include:: /includes/fact-update-operator-lexicographic-order.rst
45
45
46
+ .. include:: /includes/update-current-date.rst
47
+
46
48
If the field does not exist, :update:`$currentDate` adds the field to a
47
49
document.
48
50
@@ -80,13 +82,15 @@ as well as updating the ``status`` field to ``"D"`` and the
80
82
}
81
83
)
82
84
83
- After the operation, you can query the collection to verify the update:
85
+ .. include:: /includes/update-current-date.rst
86
+
87
+ To verify the update:
84
88
85
89
.. code-block:: javascript
86
90
87
91
db.customers.find().pretty()
88
92
89
- The updated document would resemble :
93
+ The updated document resembles :
90
94
91
95
.. code-block:: javascript
92
96
:copyable: false
@@ -101,6 +105,9 @@ The updated document would resemble:
101
105
}
102
106
}
103
107
108
+ The ``lastModified`` field is set to the date when
109
+ :update:`$currentDate` was run in the update example shown earlier.
110
+
104
111
.. _currentDate-example-agg:
105
112
106
113
Aggregation Alternative to ``$currentDate``
You can’t perform that action at this time.
0 commit comments